Skip to content

Commit 6f68466

Browse files
author
Ives van Hoorne
committed
Fix tests causing sandbox to infinite reload
1 parent 9da9e4d commit 6f68466

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

packages/app/src/sandbox/compile.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,24 @@ async function compile({
193193
initializeResizeListener();
194194
}
195195

196-
// Testing
197-
const ttt = Date.now();
198-
const testRunner = manager.testRunner;
199-
testRunner.initialize();
200-
testRunner.findTests(modules);
201-
await testRunner.runTests();
202-
const aggregatedResults = testRunner.reportResults();
203-
debug(`Test Evaluation time: ${Date.now() - ttt}ms`);
196+
try {
197+
// Testing
198+
const ttt = Date.now();
199+
const testRunner = manager.testRunner;
200+
testRunner.initialize();
201+
testRunner.findTests(modules);
202+
await testRunner.runTests();
203+
const aggregatedResults = testRunner.reportResults();
204+
debug(`Test Evaluation time: ${Date.now() - ttt}ms`);
204205

205-
dispatch({
206-
type: 'test-result',
207-
result: transformJSON(aggregatedResults),
208-
});
209-
// End - Testing
206+
dispatch({
207+
type: 'test-result',
208+
result: transformJSON(aggregatedResults),
209+
});
210+
// End - Testing
211+
} catch (e) {
212+
// Fail silently
213+
}
210214

211215
debug(`Total time: ${Date.now() - startTime}ms`);
212216

packages/app/src/sandbox/eval/manager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,12 @@ export default class Manager {
273273
* Will transpile this module and all eventual children (requires) that go with it
274274
* @param {*} entry
275275
*/
276-
async transpileModules(entry: Module) {
276+
async transpileModules(entry: Module, isEntry: boolean = true) {
277277
this.hmrStatus = 'check';
278278
this.setEnvironmentVariables();
279279
const transpiledModule = this.getTranspiledModule(entry);
280280

281-
transpiledModule.setIsEntry(true);
281+
transpiledModule.setIsEntry(isEntry);
282282

283283
const result = await transpiledModule.transpile(this);
284284
this.getTranspiledModules().forEach(t => t.postTranspile(this));

packages/app/src/sandbox/eval/tests/jest-lite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default class TestRunner {
9090

9191
async transpileTests() {
9292
for (let t of this.tests) {
93-
await this.manager.transpileModules(t);
93+
await this.manager.transpileModules(t, false);
9494
}
9595
}
9696

0 commit comments

Comments
 (0)