Skip to content

Commit b577bc1

Browse files
committed
Working & passing Nightwatch test
1 parent 88a6ece commit b577bc1

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

README.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,13 @@ https://docs.npmjs.com/getting-started/updating-local-packages
477477

478478
## Testing
479479

480-
#### Install vue-test-utils
480+
### Install vue-test-utils
481481

482482
https://github.com/vuejs/vue-test-utils
483483

484484
`npm install --save-dev @vue/test-utils`
485485

486-
#### Jest
486+
### Jest
487487

488488
https://facebook.github.io/jest/
489489

@@ -494,7 +494,7 @@ https://github.com/vuejs/vue-test-utils-jest-example
494494

495495
Vue.js Jest Docs: https://vue-test-utils.vuejs.org/guides/#testing-single-file-components-with-jest
496496

497-
###### Jest Configuration
497+
##### Jest Configuration
498498

499499
* [package.json](frontend/package.json):
500500

@@ -508,19 +508,22 @@ Vue.js Jest Docs: https://vue-test-utils.vuejs.org/guides/#testing-single-file-c
508508

509509
* [frontend/test/unit/jest.conf.js](frontend/test/unit/jest.conf.js)
510510

511-
###### Run Unit tests
511+
##### Run Unit tests
512512

513513
`npm run unit`
514514

515515
Run all tests (incl. E2E): `npm test`
516516

517517

518-
#### E2E tests with Nightwatch
518+
### E2E tests with Nightwatch
519519

520520
http://nightwatchjs.org/
521521

522522
Nightwatch controls Selenium standalone Server in own childprocess
523523

524+
##### Run E2E Tests
525+
526+
`npm run e2e`
524527

525528

526529
# Links

frontend/test/e2e/custom-assertions/elementCount.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// A custom Nightwatch assertion.
2-
// the name of the method is the filename.
3-
// can be used in tests like this:
2+
// The assertion name is the filename.
3+
// Example usage:
44
//
55
// browser.assert.elementCount(selector, count)
66
//
7-
// for how to write custom assertions see
7+
// For more information on custom assertions see:
88
// http://nightwatchjs.org/guide#writing-custom-assertions
9+
910
exports.assertion = function (selector, count) {
1011
this.message = 'Testing if element <' + selector + '> has count: ' + count
1112
this.expected = count

frontend/test/e2e/runner.js

+21-6
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
11
// 1. start the dev server using production config
22
process.env.NODE_ENV = 'testing'
3-
var server = require('../../build/dev-server.js')
43

5-
server.ready.then(() => {
4+
const webpack = require('webpack')
5+
const DevServer = require('webpack-dev-server')
6+
7+
const webpackConfig = require('../../build/webpack.prod.conf')
8+
const devConfigPromise = require('../../build/webpack.dev.conf')
9+
10+
let server
11+
12+
devConfigPromise.then(devConfig => {
13+
const devServerOptions = devConfig.devServer
14+
const compiler = webpack(webpackConfig)
15+
server = new DevServer(compiler, devServerOptions)
16+
const port = devServerOptions.port
17+
const host = devServerOptions.host
18+
return server.listen(port, host)
19+
})
20+
.then(() => {
621
// 2. run the nightwatch test suite against it
722
// to run in additional browsers:
8-
// 1. add an entry in test/e2e/nightwatch.conf.json under "test_settings"
23+
// 1. add an entry in test/e2e/nightwatch.conf.js under "test_settings"
924
// 2. add it to the --env flag below
1025
// or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
1126
// For more information on Nightwatch's config file, see
1227
// http://nightwatchjs.org/guide#settings-file
13-
var opts = process.argv.slice(2)
28+
let opts = process.argv.slice(2)
1429
if (opts.indexOf('--config') === -1) {
1530
opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js'])
1631
}
1732
if (opts.indexOf('--env') === -1) {
1833
opts = opts.concat(['--env', 'chrome'])
1934
}
2035

21-
var spawn = require('cross-spawn')
22-
var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
36+
const spawn = require('cross-spawn')
37+
const runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
2338

2439
runner.on('exit', function (code) {
2540
server.close()

frontend/test/e2e/specs/test.js frontend/test/e2e/specs/HelloAcceptance.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
.url(devServer)
1313
.waitForElementVisible('#app', 5000)
1414
.assert.elementPresent('.hello')
15-
.assert.containsText('h1', 'Welcome to Your Vue.js App')
15+
.assert.containsText('h1', 'Welcome to your Vue.js powered Spring Boot App')
1616
.assert.elementCount('img', 1)
1717
.end()
1818
}

0 commit comments

Comments
 (0)