File tree Expand file tree Collapse file tree 4 files changed +40
-9
lines changed
app/components/Preview/DevTools/Tests Expand file tree Collapse file tree 4 files changed +40
-9
lines changed Original file line number Diff line number Diff line change @@ -225,8 +225,17 @@ class Tests extends React.Component<Props, State> {
225225 immer ( this . state , state => {
226226 const currentTest =
227227 state . files [ test . path ] . tests [ testName . join ( '||||' ) ] ;
228- currentTest . status = 'running' ;
229- currentTest . running = true ;
228+ if ( ! currentTest ) {
229+ state . files [ test . path ] . tests [ testName . join ( '||||' ) ] = {
230+ status : 'running' ,
231+ running : true ,
232+ testName,
233+ path : test . path ,
234+ } ;
235+ } else {
236+ currentTest . status = 'running' ;
237+ currentTest . running = true ;
238+ }
230239 } )
231240 ) ;
232241 break ;
@@ -239,10 +248,22 @@ class Tests extends React.Component<Props, State> {
239248 immer ( this . state , state => {
240249 const existingTest =
241250 state . files [ test . path ] . tests [ testName . join ( '||||' ) ] ;
242- existingTest . status = test . status ;
243- existingTest . running = false ;
244- existingTest . errors = test . errors ;
245- existingTest . duration = test . duration ;
251+
252+ if ( existingTest ) {
253+ existingTest . status = test . status ;
254+ existingTest . running = false ;
255+ existingTest . errors = test . errors ;
256+ existingTest . duration = test . duration ;
257+ } else {
258+ state . files [ test . path ] . tests [ testName . join ( '||||' ) ] = {
259+ status : test . status ,
260+ running : false ,
261+ errors : test . errors ,
262+ duration : test . duration ,
263+ testName,
264+ path : test . path ,
265+ } ;
266+ }
246267 } )
247268 ) ;
248269 break ;
Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ export default class Manager {
107107 this . transpiledModulesByHash = { } ;
108108 this . configurations = { } ;
109109
110+ this . modules = modules ;
110111 Object . keys ( modules ) . forEach ( k => this . addModule ( modules [ k ] ) ) ;
111112 this . testRunner = new TestRunner ( this ) ;
112113
@@ -589,6 +590,8 @@ export default class Manager {
589590 this . transpileJobs = { } ;
590591 this . hardReload = false ;
591592
593+ this . modules = modules ;
594+
592595 const addedModules : Array < Module > = [ ] ;
593596 const updatedModules : Array < Module > = [ ] ;
594597
Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ export default class TestRunner {
146146 /* istanbul ignore next */
147147 async transpileTests ( ) {
148148 return Promise . all (
149- this . tests . map ( async t => {
149+ ( this . tests || [ ] ) . map ( async t => {
150150 const tModule = this . manager . getTranspiledModule ( t , '' ) ;
151151 if (
152152 tModule . source &&
@@ -162,7 +162,7 @@ export default class TestRunner {
162162 try {
163163 await this . manager . transpileModules ( t , true ) ;
164164
165- if ( ! t . source ) {
165+ if ( ! tModule . source ) {
166166 this . ranTests . delete ( t . path ) ;
167167 }
168168
@@ -211,6 +211,10 @@ export default class TestRunner {
211211 this . manager . evaluateModule ( testModule ) ;
212212 }
213213
214+ if ( this . manager . modules ) {
215+ this . findTests ( this . manager . modules ) ;
216+ }
217+
214218 // $FlowIssue
215219 const tests : Array < Module > = (await this.transpileTests()).filter(t => t ) ;
216220
Original file line number Diff line number Diff line change @@ -607,7 +607,10 @@ export default class TranspiledModule {
607607 location . reload ( ) ;
608608 return { } ;
609609 }
610- } else if ( ! this . hmrConfig || ! this . hmrConfig . isDirty ( ) ) {
610+ } else if (
611+ ! this . isTestFile &&
612+ ( ! this . hmrConfig || ! this . hmrConfig . isDirty ( ) )
613+ ) {
611614 return this . compilation . exports ;
612615 }
613616 }
You can’t perform that action at this time.
0 commit comments