feat: make editable code available in tests

This commit is contained in:
Oliver Eyton-Williams
2020-07-15 11:28:20 +02:00
committed by Mrugesh Mohapatra
parent 6e091a7cdb
commit 68b223322f
9 changed files with 120 additions and 30 deletions

View File

@@ -53,13 +53,15 @@ function buildSourceMap(files) {
// the same name 'index'. This made the last file the only file to appear in
// sources.
// A better solution is to store and handle them separately. Perhaps never
// setting the name to 'index'.
// setting the name to 'index'. Use 'contents' instead?
// TODO: is file.source ever defined?
return files.reduce(
(sources, file) => {
sources[file.name] += file.source || file.contents;
sources.editableContents += file.editableContents;
return sources;
},
{ index: '' }
{ index: '', editableContents: '' }
);
}
@@ -111,7 +113,10 @@ export function getTestRunner(buildData, { proxyLogger }, document) {
}
function getJSTestRunner({ build, sources }, proxyLogger) {
const code = sources && 'index' in sources ? sources['index'] : '';
const code = {
contents: sources.index,
editableContents: sources.editableContents
};
const testWorker = createWorker(testEvaluator, { terminateWorker: true });