You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And with the help of super cool `Automatic deploys`, we have our TravisCI build our app after every push to master - and with the checkbox set to `Wait for CI to pass before deploy` - the app gets also automatically deployed to Heroku - but only, if the TravisCI (and Coveralls...) build succeeded:
Vue.js Jest Docs: https://vue-test-utils.vuejs.org/guides/#testing-single-file-components-with-jest
473
+
474
+
A Jest Unittest looks like [Hello.test.js](frontend/test/components/Hello.test.js):
475
+
476
+
```
477
+
import { shallowMount } from '@vue/test-utils';
478
+
import Hello from '@/components/Hello'
479
+
480
+
describe('Hello.vue', () => {
481
+
it('should render correct hello message', () => {
482
+
// Given
483
+
const hellowrapped = shallowMount(Hello, {
484
+
propsData: { hellomsg: 'Welcome to your Jest powered Vue.js App' },
485
+
stubs: ['router-link', 'router-view']
486
+
});
487
+
488
+
// When
489
+
const contentH1 = hellowrapped.find('h1');
490
+
491
+
// Then
492
+
expect(contentH1.text()).toEqual('Welcome to your Jest powered Vue.js App');
493
+
})
494
+
})
495
+
```
496
+
497
+
To pass Component props while using Vue.js Router, see https://stackoverflow.com/a/37940045/4964553.
498
+
499
+
How to test components with `router-view` or `router-link`https://vue-test-utils.vuejs.org/guides/using-with-vue-router.html#testing-components-that-use-router-link-or-router-view.
500
+
501
+
The test files itself could be named `xyz.spec.js` or `xyz.test.js` - and could reside nearly everywhere in the project.
502
+
503
+
##### Jest Configuration
504
+
505
+
The Jest run-configuration is done inside the [package.json](frontend/package.json):
And don´t mind the depitction with `ERROR` - this is just a known bug: https://github.com/eirslett/frontend-maven-plugin/issues/584
549
+
550
+
551
+
##### Run Jest tests inside IntelliJ
552
+
553
+
First we need to install the NodeJS IntelliJ plugin (https://www.jetbrains.com/help/idea/developing-node-js-applications.html), which isn´t bundled with IntelliJ by default:
IntelliJ Jest integration docs: https://www.jetbrains.com/help/idea/running-unit-tests-on-jest.html
558
+
559
+
The automatic search inside the [package.json](frontend/package.json) for the Jest configuration file [jest.conf.js](frontend/test/unit/jest.conf.js) doesn´t seem to work right now, so we have to manually configure the `scripts` part of:
Great tooling: http://nightwatchjs.org/ - Nightwatch controls WebDriver / Selenium standalone Server in own childprocess and abstracts from those, providing a handy DSL for Acceptance tests:
Nightwatch is configured through the [nightwatch.conf.js](/frontend/test/e2e/nightwatch.conf.js). Watch out for breaking changes in 1.x: https://github.com/nightwatchjs/nightwatch/wiki/Migrating-to-Nightwatch-1.0
584
+
585
+
More options could be found in the docs: http://nightwatchjs.org/gettingstarted/#settings-file
586
+
587
+
588
+
#### Write Nightwatch tests
589
+
590
+
An example Nightwatch test is provided in [HelloAcceptance.test.js](/frontend/test/e2e/specs/HelloAcceptance.test.js):
591
+
592
+
```
593
+
module.exports = {
594
+
'default e2e tests': function (browser) {
595
+
// automatically uses dev Server port from /config.index.js
596
+
// default: http://localhost:8080
597
+
// see nightwatch.conf.js
598
+
const devServer = browser.globals.devServerURL
599
+
600
+
browser
601
+
.url(devServer)
602
+
.waitForElementVisible('#app', 5000)
603
+
.assert.elementPresent('.hello')
604
+
.assert.containsText('h1', 'Welcome to your Vue.js powered Spring Boot App')
605
+
.assert.elementCount('img', 1)
606
+
.end()
607
+
}
608
+
}
609
+
610
+
```
611
+
612
+
##### Run E2E Tests
613
+
614
+
`npm run e2e`
615
+
616
+
##### Current Problem with npm audit (see [NPM Security](#npm-security))
617
+
618
+
With 1.0.6, the following error occurs after an `npm run e2e`:
619
+
620
+
```
621
+
OK. 4 assertions passed. (8.625s)
622
+
The "path" argument must be of type string. Received type object
623
+
at assertPath (path.js:39:11)
624
+
at Object.join (path.js:1157:7)
625
+
at process._tickCallback (internal/process/next_tick.js:68:7)
626
+
```
627
+
628
+
With the latest 0.9.21 of Nightwatch, this issue is gone. __BUT:__ the the `npm audit` command does find vulnerabilities:
And thus the whole build process will brake. The problem are breaking changes in [Nightwatch 1.x](https://github.com/nightwatchjs/nightwatch#nightwatch-v10), that aren´t reflected inside the Vue.js Webpack template so far (they use the latest 0.9.x, which is vulnerable): https://github.com/nightwatchjs/nightwatch/wiki/Migrating-to-Nightwatch-1.0
Run `npm audit fix` to update the vulnerable packages. Only in situations, where nothing else helps, try `npm audit fix --force` (this will also install braking changes)
0 commit comments