@@ -8,12 +8,12 @@ import { webpackDevServerFacts } from '../src/webpackDevServerFacts'
88
99import { defineDevServerConfig , devServer , startDevServer } from '../'
1010
11- const requestSpecFile = ( port : number ) => {
11+ const requestSpecFile = ( file : string , port : number ) => {
1212 return new Promise ( ( res ) => {
1313 const opts = {
1414 host : 'localhost' ,
1515 port,
16- path : '/test/fixtures/foo.spec.js' ,
16+ path : encodeURI ( file ) ,
1717 }
1818
1919 const callback = ( response : EventEmitter ) => {
@@ -41,13 +41,15 @@ const webpackConfig = {
4141
4242}
4343
44- const specs : Cypress . Cypress [ 'spec' ] [ ] = [
45- {
46- name : `${ root } /test/fixtures/foo.spec.js` ,
47- relative : `${ root } /test/fixtures/foo.spec.js` ,
48- absolute : `${ root } /test/fixtures/foo.spec.js` ,
49- } ,
50- ]
44+ const createSpecs = ( name : string ) : Cypress . Cypress [ 'spec' ] [ ] => {
45+ return [
46+ {
47+ name : `${ root } /test/fixtures/${ name } ` ,
48+ relative : `${ root } /test/fixtures/${ name } ` ,
49+ absolute : `${ root } /test/fixtures/${ name } ` ,
50+ } ,
51+ ]
52+ }
5153
5254const config = {
5355 projectRoot : root ,
@@ -62,12 +64,12 @@ describe('#startDevServer', () => {
6264 webpackConfig,
6365 options : {
6466 config,
65- specs,
67+ specs : createSpecs ( 'foo.spec.js' ) ,
6668 devServerEvents : new EventEmitter ( ) ,
6769 } ,
6870 } )
6971
70- const response = await requestSpecFile ( port as number )
72+ const response = await requestSpecFile ( '/test/fixtures/foo.spec.js' , port as number )
7173
7274 expect ( response ) . to . eq ( 'const foo = () => {}\n' )
7375
@@ -76,13 +78,89 @@ describe('#startDevServer', () => {
7678 } )
7779 } )
7880
81+ it ( 'serves specs in directory with [] chars via a webpack dev server' , async ( ) => {
82+ const { port, close } = await startDevServer ( {
83+ webpackConfig,
84+ options : {
85+ config,
86+ specs : createSpecs ( '[foo]/bar.spec.js' ) ,
87+ devServerEvents : new EventEmitter ( ) ,
88+ } ,
89+ } )
90+
91+ const response = await requestSpecFile ( '/test/fixtures/[foo]/bar.spec.js' , port as number )
92+
93+ expect ( response ) . to . eq ( `it('this is a spec with a path containing []', () => {})\n` )
94+
95+ return new Promise ( ( res ) => {
96+ close ( ( ) => res ( ) )
97+ } )
98+ } )
99+
100+ it ( 'serves specs in directory with non English chars via a webpack dev server' , async ( ) => {
101+ const { port, close } = await startDevServer ( {
102+ webpackConfig,
103+ options : {
104+ config,
105+ specs : createSpecs ( 'サイプレス.spec.js' ) ,
106+ devServerEvents : new EventEmitter ( ) ,
107+ } ,
108+ } )
109+
110+ const response = await requestSpecFile ( '/test/fixtures/サイプレス.spec.js' , port as number )
111+
112+ expect ( response ) . to . eq ( `it('サイプレス', () => {})\n` )
113+
114+ return new Promise ( ( res ) => {
115+ close ( ( ) => res ( ) )
116+ } )
117+ } )
118+
119+ it ( 'serves specs in directory with ... in the file name via a webpack dev server' , async ( ) => {
120+ const { port, close } = await startDevServer ( {
121+ webpackConfig,
122+ options : {
123+ config,
124+ specs : createSpecs ( '[...bar].spec.js' ) ,
125+ devServerEvents : new EventEmitter ( ) ,
126+ } ,
127+ } )
128+
129+ const response = await requestSpecFile ( '/test/fixtures/[...bar].spec.js' , port as number )
130+
131+ expect ( response ) . to . eq ( `it('...bar', () => {})\n` )
132+
133+ return new Promise ( ( res ) => {
134+ close ( ( ) => res ( ) )
135+ } )
136+ } )
137+
138+ it ( 'serves a file with spaces via a webpack dev server' , async ( ) => {
139+ const { port, close } = await startDevServer ( {
140+ webpackConfig,
141+ options : {
142+ config,
143+ specs : createSpecs ( 'foo bar.spec.js' ) ,
144+ devServerEvents : new EventEmitter ( ) ,
145+ } ,
146+ } )
147+
148+ const response = await requestSpecFile ( '/test/fixtures/foo bar.spec.js' , port as number )
149+
150+ expect ( response ) . to . eq ( `it('this is a spec with a path containing a space', () => {})\n` )
151+
152+ return new Promise ( ( res ) => {
153+ close ( ( ) => res ( ) )
154+ } )
155+ } )
156+
79157 it ( 'emits dev-server:compile:success event on successful compilation' , async ( ) => {
80158 const devServerEvents = new EventEmitter ( )
81159 const { close } = await startDevServer ( {
82160 webpackConfig,
83161 options : {
84162 config,
85- specs,
163+ specs : createSpecs ( 'foo.spec.js' ) ,
86164 devServerEvents,
87165 } ,
88166 } )
@@ -137,7 +215,7 @@ describe('#startDevServer', () => {
137215 webpackConfig,
138216 options : {
139217 config,
140- specs,
218+ specs : createSpecs ( 'foo.spec.js' ) ,
141219 devServerEvents,
142220 } ,
143221 } )
@@ -172,13 +250,13 @@ describe('#startDevServer', () => {
172250 const { port, close } = await devServer (
173251 {
174252 config,
175- specs,
253+ specs : createSpecs ( 'foo.spec.js' ) ,
176254 devServerEvents,
177255 } ,
178256 defineDevServerConfig ( { webpackConfig } ) ,
179257 )
180258
181- const response = await requestSpecFile ( port as number )
259+ const response = await requestSpecFile ( '/test/fixtures/foo.spec.js' , port as number )
182260
183261 expect ( response ) . to . eq ( 'const foo = () => {}\n' )
184262
0 commit comments