19
js/tests/e2e/custom-assertions/elementCount.js
Normal file
19
js/tests/e2e/custom-assertions/elementCount.js
Normal file
@@ -0,0 +1,19 @@
|
||||
// A custom Nightwatch assertion.
|
||||
// The assertion name is the filename.
|
||||
// Example usage:
|
||||
//
|
||||
// browser.assert.elementCount(selector, count)
|
||||
//
|
||||
// For more information on custom assertions see:
|
||||
// http://nightwatchjs.org/guide#writing-custom-assertions
|
||||
|
||||
exports.assertion = function elementCount(selector, count) {
|
||||
this.message = `Testing if element <${selector}> has count: ${count}`;
|
||||
this.expected = count;
|
||||
this.pass = val => val === count;
|
||||
this.value = res => res.value;
|
||||
function evaluator(_selector) {
|
||||
return document.querySelectorAll(_selector).length;
|
||||
}
|
||||
this.command = cb => this.api.execute(evaluator, [selector], cb);
|
||||
};
|
||||
14
js/tests/e2e/specs/test.js
Normal file
14
js/tests/e2e/specs/test.js
Normal file
@@ -0,0 +1,14 @@
|
||||
// For authoring Nightwatch tests, see
|
||||
// http://nightwatchjs.org/guide#usage
|
||||
|
||||
module.exports = {
|
||||
'default e2e tests': (browser) => {
|
||||
browser
|
||||
.url(process.env.VUE_DEV_SERVER_URL)
|
||||
.waitForElementVisible('#app', 5000)
|
||||
.assert.elementPresent('.hello')
|
||||
.assert.containsText('h1', 'Welcome to Your Vue.js App')
|
||||
.assert.elementCount('img', 1)
|
||||
.end();
|
||||
},
|
||||
};
|
||||
8
js/tests/unit/.eslintrc.js
Normal file
8
js/tests/unit/.eslintrc.js
Normal file
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
mocha: true
|
||||
},
|
||||
rules: {
|
||||
'import/no-extraneous-dependencies': 'off'
|
||||
}
|
||||
}
|
||||
13
js/tests/unit/HelloWorld.spec.js
Normal file
13
js/tests/unit/HelloWorld.spec.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { expect } from 'chai';
|
||||
import { shallow } from '@vue/test-utils';
|
||||
import HelloWorld from '@/components/HelloWorld.vue';
|
||||
|
||||
describe('HelloWorld.vue', () => {
|
||||
it('renders props.msg when passed', () => {
|
||||
const msg = 'new message';
|
||||
const wrapper = shallow(HelloWorld, {
|
||||
propsData: { msg },
|
||||
});
|
||||
expect(wrapper.text()).to.include(msg);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user