This repository was archived by the owner on Mar 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +51
-2
lines changed Expand file tree Collapse file tree 7 files changed +51
-2
lines changed Original file line number Diff line number Diff line change 2828 <%_ if (eslint) { _%>
2929 "lint" : " eslint --ext .js,.vue --ignore-path .gitignore ." ,
3030 <%_ } _%>
31- <%_ if (test !== 'none') { _%>
31+ <%_ if (test === 'ava') { _%>
32+ "test" : " <%= test %>" ,
33+ "test:unit" : " cross-env TEST=unit ava --config unit.config.js" ,
34+ "test:e2e" : " cross-env TEST=e2e ava --config e2e.config.js" ,
35+ <%_ } else if (test !== 'none') { _%>
3236 "test" : " <%= test %>" ,
3337 <%_ } _%>
3438 "" : " "
Original file line number Diff line number Diff line change 11export default {
22 require : [ './test/ava.setup.js' ] ,
33 sources : [ '**/*.{js,vue}' ] ,
4- files : [ 'test/specs/**/*' ] ,
54 babel : {
65 testOptions : {
76 plugins : [
Original file line number Diff line number Diff line change 1+ import baseConfig from './ava.config.js'
2+
3+ export default {
4+ ...baseConfig ,
5+ files : [ 'test/e2e/**/*' ]
6+ }
Original file line number Diff line number Diff line change 1+ import { resolve } from 'path'
2+ import test from 'ava'
3+ import { Nuxt , Builder } from 'nuxt'
4+
5+ // We keep the nuxt and server instance
6+ // So we can close them at the end of the test
7+ let nuxt = null
8+
9+ // Init Nuxt.js and create a server listening on localhost:4000
10+ test . before ( async ( ) => {
11+ const config = {
12+ dev : false ,
13+ rootDir : resolve ( __dirname , '../../' )
14+ }
15+ nuxt = new Nuxt ( config )
16+ await new Builder ( nuxt ) . build ( )
17+ await nuxt . server . listen ( 4000 , 'localhost' )
18+ } , 30000 )
19+
20+ // Example of testing only generated html
21+ test ( 'Route / exits and render HTML' , async ( t ) => {
22+ const { html } = await nuxt . renderRoute ( '/' , { } )
23+ t . true ( html . includes ( 'Documentation' ) )
24+ } )
25+
26+ // Close server and ask nuxt to stop listening to file changes
27+ test . after ( 'Closing server and nuxt.js' , ( t ) => {
28+ nuxt . close ( )
29+ } )
Original file line number Diff line number Diff line change 1+ import baseConfig from './ava.config.js'
2+
3+ export default {
4+ ...baseConfig ,
5+ files : [ 'test/specs/**/*' ]
6+ }
Original file line number Diff line number Diff line change @@ -1942,6 +1942,7 @@ Generated by [AVA](https://ava.li).
19421942 'ava.config.js',
19431943 'components/Logo.vue',
19441944 'components/README.md',
1945+ 'e2e.config.js',
19451946 'layouts/README.md',
19461947 'layouts/default.vue',
19471948 'middleware/README.md',
@@ -1954,7 +1955,9 @@ Generated by [AVA](https://ava.li).
19541955 'static/favicon.ico',
19551956 'store/README.md',
19561957 'test/ava.setup.js',
1958+ 'test/e2e/index.js',
19571959 'test/specs/Logo.spec.js',
1960+ 'unit.config.js',
19581961 ]
19591962
19601963> package.json
@@ -1979,6 +1982,8 @@ Generated by [AVA](https://ava.li).
19791982 generate: 'nuxt generate',
19801983 start: 'nuxt start',
19811984 test: 'ava',
1985+ 'test:e2e': 'cross-env TEST=e2e ava --config e2e.config.js',
1986+ 'test:unit': 'cross-env TEST=unit ava --config unit.config.js',
19821987 },
19831988 }
19841989
You can’t perform that action at this time.
0 commit comments