Vue.js vuetify test-utils test:unit failing
up vote
0
down vote
favorite
My component template is correctly
<v-radio-group row :mandatory="false" v-model="gender" name="gender">
<v-radio :label="genderLabels.f" value="f" name="female"></v-radio>
<v-radio :label="genderLabels.m" value="m" name="male"></v-radio>
</v-radio-group>
genderLabels is correctly set upon mounted()
mounted() {
this.contactLang = this.language;
// eslint-disable-next-line
this.customDico = this.$validator.dictionary.container[this.language].custom;
this.genderLabels.f = this.customDico.gender.f;
this.genderLabels.m = this.customDico.gender.m;
}
there is no problem when executing yarn serve, one can see the radio label attributes..
but when I test it, they are not present...
ContactForm.spec.js
....
wrapper = mount(ContactForm, options);
console.log(wrapper.vm.genderLabels.f);
const radio = wrapper.find('[name="female"]');
console.log("radio: ", radio.html())
// then
console.log("radioLabels attributes: ", radio.attributes());
expect(radio.attributes("label")).toEqual("Mrs");
consolelog
wrapper = mount(ContactForm, options);
console.log(wrapper.vm.genderLabels.f);
const radio = wrapper.find('[name="female"]');
console.log("radio: ", radio.html())
// then
console.log("radioLabels attributes: ", radio.attributes());
expect(radio.attributes("label")).toEqual("Mrs");
● ContactForm.vue › uses the default form language
expect(received).toEqual(expected)
Expected value to equal:
"Mrs"
Received:
undefined
Difference:
Comparing two different types of values. Expected string but received undefined.
110 | // then
111 | console.log("radioLabels attributes: ", radio.attributes());
> 112 | expect(radio.attributes("label")).toEqual("Mrs");
| ^
113 | });
114 | /*
115 | it("change the form language when locale changed in store", async () => {
at Object.toEqual (tests/unit/ContactForm.spec.js:112:39)
console.log tests/unit/ContactForm.spec.js:107
Mrs
console.log tests/unit/ContactForm.spec.js:109
radio: <input aria-checked="false" role="radio" type="radio" value="f" name="female">
console.log tests/unit/ContactForm.spec.js:111
radioLabels attributes: { 'aria-checked': 'false',
role: 'radio',
type: 'radio',
value: 'f',
name: 'female' }
Test Suites: 1 failed, 1 total
where could I be wrong in my test code ?
thanks for feedback
==== UPDATE 1 ====
Using shallowMount , I gte the following in console.log(wrapper.html()); :
<vradiogroup-stub column="true" height="auto" name="gender" row="true" value="f">
<vradio-stub color="accent" onicon="$vuetify.icons.radioOn" officon="$vuetify.icons.radioOff" value="f" name="female"></vradio-stub>
<vradio-stub color="accent" onicon="$vuetify.icons.radioOn" officon="$vuetify.icons.radioOff" value="m" name="male"></vradio-stub>
</vradiogroup-stub>
using mount() , I get the follwoing in wrapper.html()
<input aria-checked="false" role="radio" type="radio" value="f" name="female">
<div role="radiogroup" class="v-input--radio-group__input">
<div class="v-radio theme--light">
<div class="v-input--selection-controls__input">
<input aria-checked="false" role="radio" type="radio" value="f" name="female">
<div class="v-input--selection-controls__ripple">
</div><i aria-hidden="true" class="v-icon material-icons theme--light">radio_button_unchecked</i></div>
<label aria-hidden="true" class="v-label theme--light" style="left: 0px; position: relative;"></label>
</div>
<div class="v-radio theme--light">
<div class="v-input--selection-controls__input">
<input aria-checked="false" role="radio" type="radio" value="m" name="male">
<div class="v-input--selection-controls__ripple">
</div>
<i aria-hidden="true" class="v-icon material-icons theme--light">radio_button_unchecked</i>
</div>
<label aria-hidden="true" class="v-label theme--light" style="left: 0px; position: relative;"></label>
</div>
</div>
It's strange ... no text in the label ...
unit-testing vue.js vuetify.js vue-test-utils
add a comment |
up vote
0
down vote
favorite
My component template is correctly
<v-radio-group row :mandatory="false" v-model="gender" name="gender">
<v-radio :label="genderLabels.f" value="f" name="female"></v-radio>
<v-radio :label="genderLabels.m" value="m" name="male"></v-radio>
</v-radio-group>
genderLabels is correctly set upon mounted()
mounted() {
this.contactLang = this.language;
// eslint-disable-next-line
this.customDico = this.$validator.dictionary.container[this.language].custom;
this.genderLabels.f = this.customDico.gender.f;
this.genderLabels.m = this.customDico.gender.m;
}
there is no problem when executing yarn serve, one can see the radio label attributes..
but when I test it, they are not present...
ContactForm.spec.js
....
wrapper = mount(ContactForm, options);
console.log(wrapper.vm.genderLabels.f);
const radio = wrapper.find('[name="female"]');
console.log("radio: ", radio.html())
// then
console.log("radioLabels attributes: ", radio.attributes());
expect(radio.attributes("label")).toEqual("Mrs");
consolelog
wrapper = mount(ContactForm, options);
console.log(wrapper.vm.genderLabels.f);
const radio = wrapper.find('[name="female"]');
console.log("radio: ", radio.html())
// then
console.log("radioLabels attributes: ", radio.attributes());
expect(radio.attributes("label")).toEqual("Mrs");
● ContactForm.vue › uses the default form language
expect(received).toEqual(expected)
Expected value to equal:
"Mrs"
Received:
undefined
Difference:
Comparing two different types of values. Expected string but received undefined.
110 | // then
111 | console.log("radioLabels attributes: ", radio.attributes());
> 112 | expect(radio.attributes("label")).toEqual("Mrs");
| ^
113 | });
114 | /*
115 | it("change the form language when locale changed in store", async () => {
at Object.toEqual (tests/unit/ContactForm.spec.js:112:39)
console.log tests/unit/ContactForm.spec.js:107
Mrs
console.log tests/unit/ContactForm.spec.js:109
radio: <input aria-checked="false" role="radio" type="radio" value="f" name="female">
console.log tests/unit/ContactForm.spec.js:111
radioLabels attributes: { 'aria-checked': 'false',
role: 'radio',
type: 'radio',
value: 'f',
name: 'female' }
Test Suites: 1 failed, 1 total
where could I be wrong in my test code ?
thanks for feedback
==== UPDATE 1 ====
Using shallowMount , I gte the following in console.log(wrapper.html()); :
<vradiogroup-stub column="true" height="auto" name="gender" row="true" value="f">
<vradio-stub color="accent" onicon="$vuetify.icons.radioOn" officon="$vuetify.icons.radioOff" value="f" name="female"></vradio-stub>
<vradio-stub color="accent" onicon="$vuetify.icons.radioOn" officon="$vuetify.icons.radioOff" value="m" name="male"></vradio-stub>
</vradiogroup-stub>
using mount() , I get the follwoing in wrapper.html()
<input aria-checked="false" role="radio" type="radio" value="f" name="female">
<div role="radiogroup" class="v-input--radio-group__input">
<div class="v-radio theme--light">
<div class="v-input--selection-controls__input">
<input aria-checked="false" role="radio" type="radio" value="f" name="female">
<div class="v-input--selection-controls__ripple">
</div><i aria-hidden="true" class="v-icon material-icons theme--light">radio_button_unchecked</i></div>
<label aria-hidden="true" class="v-label theme--light" style="left: 0px; position: relative;"></label>
</div>
<div class="v-radio theme--light">
<div class="v-input--selection-controls__input">
<input aria-checked="false" role="radio" type="radio" value="m" name="male">
<div class="v-input--selection-controls__ripple">
</div>
<i aria-hidden="true" class="v-icon material-icons theme--light">radio_button_unchecked</i>
</div>
<label aria-hidden="true" class="v-label theme--light" style="left: 0px; position: relative;"></label>
</div>
</div>
It's strange ... no text in the label ...
unit-testing vue.js vuetify.js vue-test-utils
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My component template is correctly
<v-radio-group row :mandatory="false" v-model="gender" name="gender">
<v-radio :label="genderLabels.f" value="f" name="female"></v-radio>
<v-radio :label="genderLabels.m" value="m" name="male"></v-radio>
</v-radio-group>
genderLabels is correctly set upon mounted()
mounted() {
this.contactLang = this.language;
// eslint-disable-next-line
this.customDico = this.$validator.dictionary.container[this.language].custom;
this.genderLabels.f = this.customDico.gender.f;
this.genderLabels.m = this.customDico.gender.m;
}
there is no problem when executing yarn serve, one can see the radio label attributes..
but when I test it, they are not present...
ContactForm.spec.js
....
wrapper = mount(ContactForm, options);
console.log(wrapper.vm.genderLabels.f);
const radio = wrapper.find('[name="female"]');
console.log("radio: ", radio.html())
// then
console.log("radioLabels attributes: ", radio.attributes());
expect(radio.attributes("label")).toEqual("Mrs");
consolelog
wrapper = mount(ContactForm, options);
console.log(wrapper.vm.genderLabels.f);
const radio = wrapper.find('[name="female"]');
console.log("radio: ", radio.html())
// then
console.log("radioLabels attributes: ", radio.attributes());
expect(radio.attributes("label")).toEqual("Mrs");
● ContactForm.vue › uses the default form language
expect(received).toEqual(expected)
Expected value to equal:
"Mrs"
Received:
undefined
Difference:
Comparing two different types of values. Expected string but received undefined.
110 | // then
111 | console.log("radioLabels attributes: ", radio.attributes());
> 112 | expect(radio.attributes("label")).toEqual("Mrs");
| ^
113 | });
114 | /*
115 | it("change the form language when locale changed in store", async () => {
at Object.toEqual (tests/unit/ContactForm.spec.js:112:39)
console.log tests/unit/ContactForm.spec.js:107
Mrs
console.log tests/unit/ContactForm.spec.js:109
radio: <input aria-checked="false" role="radio" type="radio" value="f" name="female">
console.log tests/unit/ContactForm.spec.js:111
radioLabels attributes: { 'aria-checked': 'false',
role: 'radio',
type: 'radio',
value: 'f',
name: 'female' }
Test Suites: 1 failed, 1 total
where could I be wrong in my test code ?
thanks for feedback
==== UPDATE 1 ====
Using shallowMount , I gte the following in console.log(wrapper.html()); :
<vradiogroup-stub column="true" height="auto" name="gender" row="true" value="f">
<vradio-stub color="accent" onicon="$vuetify.icons.radioOn" officon="$vuetify.icons.radioOff" value="f" name="female"></vradio-stub>
<vradio-stub color="accent" onicon="$vuetify.icons.radioOn" officon="$vuetify.icons.radioOff" value="m" name="male"></vradio-stub>
</vradiogroup-stub>
using mount() , I get the follwoing in wrapper.html()
<input aria-checked="false" role="radio" type="radio" value="f" name="female">
<div role="radiogroup" class="v-input--radio-group__input">
<div class="v-radio theme--light">
<div class="v-input--selection-controls__input">
<input aria-checked="false" role="radio" type="radio" value="f" name="female">
<div class="v-input--selection-controls__ripple">
</div><i aria-hidden="true" class="v-icon material-icons theme--light">radio_button_unchecked</i></div>
<label aria-hidden="true" class="v-label theme--light" style="left: 0px; position: relative;"></label>
</div>
<div class="v-radio theme--light">
<div class="v-input--selection-controls__input">
<input aria-checked="false" role="radio" type="radio" value="m" name="male">
<div class="v-input--selection-controls__ripple">
</div>
<i aria-hidden="true" class="v-icon material-icons theme--light">radio_button_unchecked</i>
</div>
<label aria-hidden="true" class="v-label theme--light" style="left: 0px; position: relative;"></label>
</div>
</div>
It's strange ... no text in the label ...
unit-testing vue.js vuetify.js vue-test-utils
My component template is correctly
<v-radio-group row :mandatory="false" v-model="gender" name="gender">
<v-radio :label="genderLabels.f" value="f" name="female"></v-radio>
<v-radio :label="genderLabels.m" value="m" name="male"></v-radio>
</v-radio-group>
genderLabels is correctly set upon mounted()
mounted() {
this.contactLang = this.language;
// eslint-disable-next-line
this.customDico = this.$validator.dictionary.container[this.language].custom;
this.genderLabels.f = this.customDico.gender.f;
this.genderLabels.m = this.customDico.gender.m;
}
there is no problem when executing yarn serve, one can see the radio label attributes..
but when I test it, they are not present...
ContactForm.spec.js
....
wrapper = mount(ContactForm, options);
console.log(wrapper.vm.genderLabels.f);
const radio = wrapper.find('[name="female"]');
console.log("radio: ", radio.html())
// then
console.log("radioLabels attributes: ", radio.attributes());
expect(radio.attributes("label")).toEqual("Mrs");
consolelog
wrapper = mount(ContactForm, options);
console.log(wrapper.vm.genderLabels.f);
const radio = wrapper.find('[name="female"]');
console.log("radio: ", radio.html())
// then
console.log("radioLabels attributes: ", radio.attributes());
expect(radio.attributes("label")).toEqual("Mrs");
● ContactForm.vue › uses the default form language
expect(received).toEqual(expected)
Expected value to equal:
"Mrs"
Received:
undefined
Difference:
Comparing two different types of values. Expected string but received undefined.
110 | // then
111 | console.log("radioLabels attributes: ", radio.attributes());
> 112 | expect(radio.attributes("label")).toEqual("Mrs");
| ^
113 | });
114 | /*
115 | it("change the form language when locale changed in store", async () => {
at Object.toEqual (tests/unit/ContactForm.spec.js:112:39)
console.log tests/unit/ContactForm.spec.js:107
Mrs
console.log tests/unit/ContactForm.spec.js:109
radio: <input aria-checked="false" role="radio" type="radio" value="f" name="female">
console.log tests/unit/ContactForm.spec.js:111
radioLabels attributes: { 'aria-checked': 'false',
role: 'radio',
type: 'radio',
value: 'f',
name: 'female' }
Test Suites: 1 failed, 1 total
where could I be wrong in my test code ?
thanks for feedback
==== UPDATE 1 ====
Using shallowMount , I gte the following in console.log(wrapper.html()); :
<vradiogroup-stub column="true" height="auto" name="gender" row="true" value="f">
<vradio-stub color="accent" onicon="$vuetify.icons.radioOn" officon="$vuetify.icons.radioOff" value="f" name="female"></vradio-stub>
<vradio-stub color="accent" onicon="$vuetify.icons.radioOn" officon="$vuetify.icons.radioOff" value="m" name="male"></vradio-stub>
</vradiogroup-stub>
using mount() , I get the follwoing in wrapper.html()
<input aria-checked="false" role="radio" type="radio" value="f" name="female">
<div role="radiogroup" class="v-input--radio-group__input">
<div class="v-radio theme--light">
<div class="v-input--selection-controls__input">
<input aria-checked="false" role="radio" type="radio" value="f" name="female">
<div class="v-input--selection-controls__ripple">
</div><i aria-hidden="true" class="v-icon material-icons theme--light">radio_button_unchecked</i></div>
<label aria-hidden="true" class="v-label theme--light" style="left: 0px; position: relative;"></label>
</div>
<div class="v-radio theme--light">
<div class="v-input--selection-controls__input">
<input aria-checked="false" role="radio" type="radio" value="m" name="male">
<div class="v-input--selection-controls__ripple">
</div>
<i aria-hidden="true" class="v-icon material-icons theme--light">radio_button_unchecked</i>
</div>
<label aria-hidden="true" class="v-label theme--light" style="left: 0px; position: relative;"></label>
</div>
</div>
It's strange ... no text in the label ...
unit-testing vue.js vuetify.js vue-test-utils
unit-testing vue.js vuetify.js vue-test-utils
edited Nov 12 at 14:56
asked Nov 12 at 10:42
erwin
3,9341144112
3,9341144112
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
SOLVED...
I do not understand yet why ... but I need to set my test as asynchronous :
then I can get the label attribute set to the correct value ...
it("uses the default form language", async () => {
...
wrapper = shallowMount(ContactForm, options);
await wrapper.vm.$nextTick();
const radioInput = wrapper.find('[name="female"]');
console.log(radioInput.html());
console.log tests/unit/ContactForm.spec.js:110
<vradio-stub color="accent" onicon="$vuetify.icons.radioOn"
officon="$vuetify.icons.radioOff"
value="f" name="female" label="Mrs"></vradio-stub>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260448%2fvue-js-vuetify-test-utils-testunit-failing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
SOLVED...
I do not understand yet why ... but I need to set my test as asynchronous :
then I can get the label attribute set to the correct value ...
it("uses the default form language", async () => {
...
wrapper = shallowMount(ContactForm, options);
await wrapper.vm.$nextTick();
const radioInput = wrapper.find('[name="female"]');
console.log(radioInput.html());
console.log tests/unit/ContactForm.spec.js:110
<vradio-stub color="accent" onicon="$vuetify.icons.radioOn"
officon="$vuetify.icons.radioOff"
value="f" name="female" label="Mrs"></vradio-stub>
add a comment |
up vote
0
down vote
SOLVED...
I do not understand yet why ... but I need to set my test as asynchronous :
then I can get the label attribute set to the correct value ...
it("uses the default form language", async () => {
...
wrapper = shallowMount(ContactForm, options);
await wrapper.vm.$nextTick();
const radioInput = wrapper.find('[name="female"]');
console.log(radioInput.html());
console.log tests/unit/ContactForm.spec.js:110
<vradio-stub color="accent" onicon="$vuetify.icons.radioOn"
officon="$vuetify.icons.radioOff"
value="f" name="female" label="Mrs"></vradio-stub>
add a comment |
up vote
0
down vote
up vote
0
down vote
SOLVED...
I do not understand yet why ... but I need to set my test as asynchronous :
then I can get the label attribute set to the correct value ...
it("uses the default form language", async () => {
...
wrapper = shallowMount(ContactForm, options);
await wrapper.vm.$nextTick();
const radioInput = wrapper.find('[name="female"]');
console.log(radioInput.html());
console.log tests/unit/ContactForm.spec.js:110
<vradio-stub color="accent" onicon="$vuetify.icons.radioOn"
officon="$vuetify.icons.radioOff"
value="f" name="female" label="Mrs"></vradio-stub>
SOLVED...
I do not understand yet why ... but I need to set my test as asynchronous :
then I can get the label attribute set to the correct value ...
it("uses the default form language", async () => {
...
wrapper = shallowMount(ContactForm, options);
await wrapper.vm.$nextTick();
const radioInput = wrapper.find('[name="female"]');
console.log(radioInput.html());
console.log tests/unit/ContactForm.spec.js:110
<vradio-stub color="accent" onicon="$vuetify.icons.radioOn"
officon="$vuetify.icons.radioOff"
value="f" name="female" label="Mrs"></vradio-stub>
answered Nov 12 at 16:00
erwin
3,9341144112
3,9341144112
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53260448%2fvue-js-vuetify-test-utils-testunit-failing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown