@@ -51,25 +51,25 @@ const spawnP = (cmd, args, options) => new Promise((resolve, reject) => {
51
51
child . stderr . on ( 'data' , data => { output += data . toString ( ) ; } ) ;
52
52
child . on ( 'close' , code => ( code === 0 ? resolve ( code ) : reject ( output ) ) ) ;
53
53
} ) ;
54
- const buildable = async ( t , dir ) => {
54
+ const buildable = async ( t , dir , args = [ ] ) => {
55
55
try {
56
- await spawnP ( 'yarn' , [ 'build' ] , { cwd : dir , stdio : 'pipe' } ) ;
56
+ await spawnP ( 'yarn' , [ 'build' , ... args ] , { cwd : dir , stdio : 'pipe' } ) ;
57
57
t . pass ( ) ;
58
58
} catch ( output ) {
59
59
t . fail ( `Failed to build project:\n\n${ output } ` ) ;
60
60
}
61
61
} ;
62
- const testable = async ( t , dir ) => {
62
+ const testable = async ( t , dir , args = [ ] ) => {
63
63
try {
64
- await spawnP ( 'yarn' , [ 'test' ] , { cwd : dir , stdio : 'pipe' } ) ;
64
+ await spawnP ( 'yarn' , [ 'test' , ... args ] , { cwd : dir , stdio : 'pipe' } ) ;
65
65
t . pass ( ) ;
66
66
} catch ( output ) {
67
67
t . fail ( `Failed to test project:\n\n${ output } ` ) ;
68
68
}
69
69
} ;
70
- const lintable = async ( t , dir ) => {
70
+ const lintable = async ( t , dir , args = [ ] ) => {
71
71
try {
72
- await spawnP ( 'yarn' , [ 'lint' ] , { cwd : dir , stdio : 'pipe' } ) ;
72
+ await spawnP ( 'yarn' , [ 'lint' , ... args ] , { cwd : dir , stdio : 'pipe' } ) ;
73
73
t . pass ( ) ;
74
74
} catch ( output ) {
75
75
t . fail ( `Failed to lint project:\n\n${ output } ` ) ;
@@ -97,16 +97,27 @@ Object.keys(tests).forEach(projectName => {
97
97
project : projectName ,
98
98
testRunner : tester || false
99
99
} ) ;
100
+ const pkgPath = join ( dir , 'package.json' ) ;
100
101
101
102
t . truthy ( dir ) ;
102
- assert . file ( join ( dir , 'package.json' ) ) ;
103
+ assert . file ( pkgPath ) ;
103
104
assert . file ( join ( dir , '.neutrinorc.js' ) ) ;
104
105
assert . file ( join ( dir , 'webpack.config.js' ) ) ;
105
106
assert . file ( join ( dir , '.eslintrc.js' ) ) ;
106
107
107
108
await lintable ( t , dir ) ;
108
109
await buildable ( t , dir ) ;
109
110
111
+ const pkg = require ( pkgPath ) ; // eslint-disable-line import/no-dynamic-require
112
+
113
+ // Building in development mode to emulating running webpack-dev-server
114
+ // or webpack --watch without actually spawning the process and waiting.
115
+ // TODO: Find a way in the future to actually test that the spawned watchers
116
+ // produce the expected result.
117
+ if ( 'start' in pkg . scripts ) {
118
+ await buildable ( t , dir , [ '--' , '--mode' , 'development' ] ) ;
119
+ }
120
+
110
121
if ( tester ) {
111
122
if ( tester === packages . JEST ) {
112
123
assert . file ( join ( dir , 'jest.config.js' ) ) ;
0 commit comments