Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add e2e testing support using Ava #303

Merged
merged 29 commits into from
Aug 31, 2019
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1121634
chore(ava): update ava configuration
vinayakkulkarni Jul 28, 2019
ed2d6ec
feat(testing): add e2e testing support
vinayakkulkarni Jul 28, 2019
8f62a3c
feat(testing): update unit testing support
vinayakkulkarni Jul 28, 2019
fe9dec7
chore: update snapshots
vinayakkulkarni Jul 28, 2019
98ab45e
fix: update rendered package.json
vinayakkulkarni Jul 28, 2019
5439b08
feat(e2e): add e2e tests
vinayakkulkarni Jul 28, 2019
fbbc10d
chore: update snapshots
vinayakkulkarni Jul 28, 2019
5d883a1
Merge remote-tracking branch 'upstream/master' into ava-add-e2e-testing
vinayakkulkarni Jul 30, 2019
dba8ce9
chore: update snapshot
vinayakkulkarni Jul 30, 2019
09b2739
chore: fix if-else logic for ava tests
vinayakkulkarni Aug 5, 2019
fb7b3d2
Merge remote-tracking branch 'upstream/master' into ava-add-e2e-testing
vinayakkulkarni Aug 5, 2019
05b1b13
fix: update testing logic in package.json
vinayakkulkarni Aug 5, 2019
c1c00fd
fix: update else-if statement
vinayakkulkarni Aug 5, 2019
75e9cf0
chore: update snapshots
vinayakkulkarni Aug 5, 2019
b507d9d
Merge remote-tracking branch 'upstream/master' into ava-add-e2e-testing
vinayakkulkarni Aug 5, 2019
edfa4c8
chore: update snapshots
vinayakkulkarni Aug 5, 2019
cd2801b
style: move e2e test config inside `./tests` dir
vinayakkulkarni Aug 5, 2019
36d35c5
style: move unit tests config inside `./tests` dir
vinayakkulkarni Aug 5, 2019
086875c
chore: update npm script for testing, use correct config files
vinayakkulkarni Aug 5, 2019
7fe79f4
chore: update snapshots
vinayakkulkarni Aug 5, 2019
325e0ea
revert: e2e & unit config files in root directory
vinayakkulkarni Aug 5, 2019
69a4a48
revert: update npm script for testing
vinayakkulkarni Aug 5, 2019
c3cc653
chore: update snapshots
vinayakkulkarni Aug 5, 2019
462aea2
Merge branch 'master' into ava-add-e2e-testing
vinayakkulkarni Aug 7, 2019
b89ce01
chore: update test snapshot
vinayakkulkarni Aug 7, 2019
d7a37f7
Merge branch 'master' into ava-add-e2e-testing
vinayakkulkarni Aug 12, 2019
a5584e0
chore: update snapshot
vinayakkulkarni Aug 12, 2019
3b2caaa
Merge remote-tracking branch 'upstream/master' into ava-add-e2e-testing
vinayakkulkarni Aug 31, 2019
ffe4362
fix: update snapshot test
vinayakkulkarni Aug 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion template/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
<%_ if (eslint) { _%>
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
<%_ } _%>
<%_ if (test !== 'none') { _%>
<%_ if (test === 'ava') { _%>
"test": "<%= test %>",
"test:unit": "cross-env TEST=unit ava --config ./tests/unit.config.js",
"test:e2e": "cross-env TEST=e2e ava --config ./tests/e2e.config.js",
<%_ } else if (test !== 'none') { _%>
"test": "<%= test %>",
<%_ } _%>
"": ""
Expand Down
1 change: 0 additions & 1 deletion template/frameworks/ava/ava.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export default {
require: ['./test/ava.setup.js'],
sources: ['**/*.{js,vue}'],
files: ['test/specs/**/*'],
tap: true,
verbose: true
}
29 changes: 29 additions & 0 deletions template/frameworks/ava/test/e2e/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { resolve } from 'path'
import test from 'ava'
import { Nuxt, Builder } from 'nuxt'

// We keep the nuxt and server instance
// So we can close them at the end of the test
let nuxt = null

// Init Nuxt.js and create a server listening on localhost:4000
test.before(async () => {
const config = {
dev: false,
rootDir: resolve(__dirname, '../../')
}
nuxt = new Nuxt(config)
await new Builder(nuxt).build()
await nuxt.server.listen(4000, 'localhost')
}, 30000)

// Example of testing only generated html
test('Route / exits and render HTML', async (t) => {
const { html } = await nuxt.renderRoute('/', {})
t.true(html.includes('Documentation'))
})

// Close server and ask nuxt to stop listening to file changes
test.after('Closing server and nuxt.js', (t) => {
nuxt.close()
})
6 changes: 6 additions & 0 deletions template/frameworks/ava/tests/e2e.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import baseConfig from '../ava.config.js'

export default {
...baseConfig,
files: ['../test/e2e/**/*']
}
6 changes: 6 additions & 0 deletions template/frameworks/ava/tests/unit.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import baseConfig from '../ava.config.js'

export default {
...baseConfig,
files: ['../test/specs/**/*']
}
5 changes: 5 additions & 0 deletions test/snapshots/index.test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,10 @@ Generated by [AVA](https://ava.li).
'static/favicon.ico',
'store/README.md',
'test/ava.setup.js',
'test/e2e/index.js',
'test/specs/Logo.spec.js',
'tests/e2e.config.js',
'tests/unit.config.js',
]

> package.json
Expand All @@ -1881,6 +1884,8 @@ Generated by [AVA](https://ava.li).
generate: 'nuxt generate',
start: 'nuxt start',
test: 'ava',
'test:e2e': 'cross-env TEST=e2e ava --config ./tests/e2e.config.js',
'test:unit': 'cross-env TEST=unit ava --config ./tests/unit.config.js',
},
}

Expand Down
Binary file modified test/snapshots/index.test.js.snap
Binary file not shown.