- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
作为 vue 新手,我为一个组件编写了一个测试。测试是绿色的。但是,在被测组件(v-layout、v-flex)中使用 vuetify 时,控制台输出中会列出错误消息。在组件(v-layout、v-flex)中移除 vuetify 时,它们会消失。如何使用 vuetify 并仍然避免这些消息?
组件 TestForm
<script>
import "@/assets/Styles";
import {cloneDeep} from "lodash";
import VForm from "vuetify/es5/components/VForm";
import VBtn from "vuetify/es5/components/VBtn";
import {VContainer, VContent, VFlex, VLayout, VSpacer} from "vuetify/es5/components/VGrid";
import VTextField from "vuetify/es5/components/VTextField";
import {VCard, VCardText, VCardTitle} from "vuetify/es5/components/VCard";
import TestModelData from "@/api/model/example/TestModelData";
import TestData from "@/api/model/example/TestData";
import TestStatus from "@/api/model/example/TestStatus";
import TestStatusSelect from "@/components/common/TestStatusSelect";
export default {
components: {
VBtn,
VForm,
TestModelData, TestData, TestStatus, TestStatusSelect,
VCard, VCardTitle, VCardText,
VContainer, VContent, VLayout, VFlex, VSpacer,
VTextField
},
props: {
testModelData: TestModelData
},
data() {
return {
currentTestModelData: this.testModelData,
testData: this.testData ? cloneDeep(this.testData) : new TestData()
};
},
watch: {
"testModelData.testdata": function (val) {
console.log("Testdata has changed;", val);
if (val) {
this.testData = cloneDeep(val);
} else {
this.testData = new TestData();
}
}
},
computed: {
readOnly: function () {
if (this.testData.testStatus.id !== TestStatus.FIRST.id) {
return true;
} else {
return false;
}
}
},
methods: {
onFormChange(event) {
console.log("Changed: ", event);
this.$store.dispatch({
type: "testModelData/setTestData",
testData: this.testData
});
}
}
};
</script>
<template>
<v-form ref="form">
<v-layout wrap>
<v-flex xs12 lg6>
<TestStatusSelect
ref="testDataSelect"
v-model="testData.testStatus"
@change="onFormChange($event)"/>
</v-flex>
</v-layout>
</v-form>
<!-- when comment the above and uncomment the below the error messages disappear -->
<!--<v-form ref="form">-->
<!--<TestStatusSelect-->
<!--ref="testDataSelect"-->
<!--v-model="testData.testStatus"-->
<!--@change="onFormChange($event)"/>-->
<!--</v-form>-->
</template>
import VueTestUtils, {createLocalVue, mount} from "@vue/test-utils";
import Vuex from 'vuex';
import Vuetify from 'vuetify';
import TestForm from "@/components/example/TestForm";
import TestModelData from "@/api/model/example/TestModelData";
VueTestUtils.config.provide['$options'] = {};
const localVue = createLocalVue();
localVue.use(Vuex);
localVue.use(Vuetify);
const TEST_MODEL_DATA = TestModelData.fromJSON({
"id": 1,
"testdata": {
"id": 1,
"name": "Foo",
"testStatus": 0,
}
});
describe('TestForm Tests', () => {
test('TestForm select testStatus', () => {
const setTestData = jest.fn();
const getters = {
"current": jest.fn().mockImplementation(() => {
return TEST_MODEL_DATA;
}),
"hasUnsavedChanges": jest.fn().mockReturnValue(false),
};
const store = new Vuex.Store({
modules: {
testModelData: {
namespaced: true,
getters: getters,
actions: {setTestData}
}
}
});
const wrapper = mount(TestForm, {
store, localVue, propsData: {
testModelData: TEST_MODEL_DATA
}
});
const first = wrapper.findAll('.v-list__tile--link').at(1);
first.trigger('click');
expect(setTestData).toHaveBeenCalled();
});
});
<script>
import VSelect from "vuetify/es5/components/VSelect";
import TestStatus from "@/api/model/example/TestStatus";
export default {
components: {
VSelect
},
props: ["value", "disabled"],
data() {
return {
testStatuses: TestStatus.ALL,
testStatus: this.value ? this.value : TestStatus.FIRST
};
},
watch: {
value(val) {
if (this.testStatus.id !== val.id) {
console.log('VALUE');
this.testStatus = val;
}
},
testStatus(val, oldVal) {
if (val.id !== oldVal.id) {
this.$emit("input", val);
this.$emit("change", val);
}
}
}
};
</script>
<template>
<v-select
ref="testStatusSelect"
:disabled="disabled"
label="Result"
:items="testStatuses"
item-text="name"
item-value="id"
v-model="testStatus"
return-object>
</v-select>
</template>
import TestData from "@/api/model/example/TestData";
class TestModelData {
constructor() {
this.id = null;
this.testData = null;
}
fromJSON(json) {
this.id = json.id;
this.testData = TestData.fromJSON(json.testData);
}
toJSON() {
const o = {
id: this.id,
};
if (this.testData) {
a.testData = this.testData.toJSON();
}
return o;
}
static fromJSON(json) {
if (!json) {
return null;
} else {
const a = new TestModelData();
a.fromJSON(json);
return a;
}
}
}
export default TestModelData;
import TestStatus from "@/api/model/example/TestStatus";
class TestData {
constructor() {
this.id = null;
this.name = null;
this.testStatus = TestStatus.FIRST;
}
fromJSON(json) {
this.id = json.id;
this.name = json.name;
this.testStatus = json.testStatus !== null ? TestStatus.fromJSON(json.testStatus) : null;
}
toJSON() {
const o = {
id: this.id,
};
o.name = this.name;
o.testStatus = this.testStatus ? this.testStatus.toJSON() : null;
return o;
}
static fromJSON(json) {
if (!json) {
return null;
} else {
const a = new TestData();
a.fromJSON(json);
return a;
}
}
}
export default TestData;
import PropTypes from "prop-types";
import Definition from "../Definition";
class TestStatus extends Definition {
constructor(id, name) {
super();
this.id = id;
this.name = name;
}
static FIRST = new TestStatus(0, "first");
static SECOND = new TestStatus(1, "second");
static ALL = [
TestStatus.FIRST,
TestStatus.SECOND
];
toJSON() {
return this.id;
}
static fromJSON(json) {
if (json === TestStatus.FIRST.id) {
return TestStatus.FIRST;
}
else if (json === TestStatus.SECOND.id) {
return TestStatus.SECOND;
}
console.error("TestStatus unknown", json);
throw new Error(`TestStatus ${json} unknown`, json);
}
}
TestStatus.prototype.PROPTYPES = {
id: PropTypes.number,
name: PropTypes.string,
};
export default TestStatus;
console.error node_modules/@vue/test-utils/dist/vue-test-utils.js:15
[vue-test-utils]: an extended child component <VBtn> has been modified to ensure it has the correct instance properties. This means it is not possible to find the component with a component selector. To find the component, you must stub it manually using the stubs mounting option.
console.error node_modules/@vue/test-utils/dist/vue-test-utils.js:15
[vue-test-utils]: an extended child component <VCard> has been modified to ensure it has the correct instance properties. This means it is not possible to find the component with a component selector. To find the component, you must stub it manually using the stubs mounting option.
console.error node_modules/@vue/test-utils/dist/vue-test-utils.js:15
[vue-test-utils]: an extended child component <VCardTitle> has been modified to ensure it has the correct instance properties. This means it is not possible to find the component with a component selector. To find the component, you must stub it manually using the stubs mounting option.
console.error node_modules/@vue/test-utils/dist/vue-test-utils.js:15
[vue-test-utils]: an extended child component <VCardText> has been modified to ensure it has the correct instance properties. This means it is not possible to find the component with a component selector. To find the component, you must stub it manually using the stubs mounting option.
console.warn node_modules/vuetify/es5/util/console.js:32
[Vuetify] Unable to locate target [data-app]
found in
---> <VMenu>
<VSelect>
<TestStatusSelect>
<VForm>
<VCard>
<Anonymous>
<Root>
console.error node_modules/vue/dist/vue.common.js:593
[Vue warn]: $listeners is readonly.
found in
---> <VSelect>
<TestStatusSelect>
<VForm>
<VCard>
<Anonymous>
<Root>
console.log src/components/example/TestForm.vue:800
Changed: TestStatus {
_clazz: [Getter/Setter],
id: [Getter/Setter],
name: [Getter/Setter] }
console.error node_modules/vue/dist/vue.common.js:593
[Vue warn]: $listeners is readonly.
found in
---> <VSelect>
<TestStatusSelect>
<VForm>
<VCard>
<Anonymous>
<Root>
console.error node_modules/vue/dist/vue.common.js:593
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "value"
found in
---> <VSelect>
<TestStatusSelect>
<VForm>
<VCard>
<Anonymous>
<Root>
console.error node_modules/vue/dist/vue.common.js:593
[Vue warn]: $listeners is readonly.
found in
---> <VSelect>
<TestStatusSelect>
<VForm>
<VCard>
<Anonymous>
<Root>
最佳答案
this thread 中有一些解决方案/变通方法.
这是对我有用的,我将它添加到了我的测试主体的顶部:
document.body.setAttribute('data-app', true)
关于jestjs - vuetify + jest 列出了错误消息,尽管 test 是绿色的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51761455/
有没有办法用 Jestjs 编写更多数据驱动的测试? 我想出了这样的东西: it('assignments and declarations', () => { testCases.f
我想知道如何为 package.json 中的所有 JestJS 测试设置全局超时? 默认的 5000 毫秒对于我的测试来说是不够的。我不想为我的每个测试执行以下代码: it('should retu
我们正在使用 Jest/Enzyme 进行我们的 React 集成测试。我们有一个组件在等待 iframe 加载时显示微调器。当此页面在真实世界的浏览器环境中加载时,微调器会明显显示。但是,在测试 中
Jest 不提供我的手动模拟。一切似乎都在正确的目录中。我错过了什么? src/adapters/__mocks__/Foo.js const spy = jest.genMockFromModule
我对 Jest 有点陌生,所以如果这是一个明显的答案,请原谅我,但在滚动浏览文档后我找不到答案。 我有一个函数 (funcA),它将一个不同长度的数组传递给另一个函数 (funcB),具体取决于 fu
我正在GitLab CI中进行代码覆盖率的玩笑测试,并且GitLab从gitlab中的运行程序的标准输出中捕获了百分比。 jest --coverage在stdout中产生覆盖率,而gitlab使用/
我正在使用Jest运行Selenium测试。我希望登录测试在其余的Webapp功能测试之前进行。我可以使用jest -i依次运行文件,但找不到控制文件运行顺序的方法。我尝试更改文件名,希望它按文件名的
这个和这个不一样enzyme-to-snapshot-render-object-as-json因为 这里我想生成对象的带有JSON定义的快照 另一个我想为组件生成的 only for HTML 生成
我编写了一个脚本,其主要目的是向某些表格的单元格添加新元素。 测试是通过类似这样的方式完成的: document.body.innerHTML = `
我看到有两个配置选项可以在每次测试之前运行一些代码:setupFiles和setupFilesAfterEnv。在我看来,setupFilesAfterEnv提供了更大的灵活性(我可以使用jest,b
我已经找到了一些特定于版本的questions on SO,用于 Jest 单元测试,并将其结果发布在VSTS构建测试结果标签中。但是找不到适当的解决方案。 最佳答案 经过一些研究,我发现Jest t
我想在Jest测试代码中摆脱全局变量。具体来说describe,it和expect: describe('Welcome (Snapshot)', () => { it('Welcome rend
我想测试一个非常简单的JS函数 export function displaySpinner() { const loadingOverlayDOM = document.createElem
该项目具有客户端应用程序和服务器站点代码,一旦项目在本地构建,它将把所有构建的前端和后端 Assets 放入 build目录,它包含客户端需要使用的所有静态 Assets (所有测试用例也包括在那里)
我了解Jest是用于JavaScript的开发人员的单元测试工具。 Jest是类似于Selenium的基于浏览器的测试工具还是功能测试工具? 最佳答案 该npm库可以与您的jest测试集成在一起,以在
我发现“笑话快照摘要”有点令人困惑。在我们的一个存储库中运行测试后,我得到以下摘要: Snapshot Summary › 2 snapshots written in 1 test suite.
我对 Jest 用于运行测试的顺序有一些疑问。 假设我有两个测试: module1.spec.ts module2.spec.ts 这些模块中的每一个都使用一个公共(public)数据库。在每个文件的
我想为我的代码库中的所有文件运行覆盖率报告,包括那些目前没有任何测试的文件。 我正在使用这个命令: jest --coverage --collectCoverageFrom='src/feature
我想在 jest 中断言数组包含具有某些属性的对象,例如: [ { id: 1, name: 'A' }, { id: 2, name: 'B' }, { id: 3 }
我正在开发一个文本生成器,我想将生成的字符串与存储在示例文件中的文本进行比较。文件某些行有缩进,在 TS/js 中构造这些字符串非常麻烦 是否有一种简单的方法可以从相对于当前测试甚至 Jest 项目根
我是一名优秀的程序员,十分优秀!