This is my vue.js 2.0 Mocha Chai testing unit, I can't get an element by Id, maybe you have a solution ? I need to test if the input field gets correctly displayed ... :
import { expect } from "chai";
import { shallowMount } from "@vue/test-utils";
import Register from "@/components/Register.vue";
const wrapper = shallowMount(Register);
describe("Register tests", () => {
it("Should display an Email input", () => {
expect(wrapper.vm.$el.querySelector("input[type='email']") !==null).to.be.true
});// IT WORKS
it("Should display a name input", () => {
expect(wrapper.vm.$el.getElementById('name') !== null).to.be.true
});
});
This is the error :
1) Register tests
Should display a name input:
TypeError: wrapper.vm.$el.getElementById is not a function
at Context.it (dist\js\webpack:\tests\unit\register.spec.js:26:1)
This is the element that I want to test. ;
<input type="text" class="form-control form-control-user" min="1" v-model="user.name" name="name" value ="name" id="name" placeholder="name">