fix: only include frame-runner when running tests (#44337)

* fix: only include frame-runner when running tests

* fix: handle missing options

* test: use test runner for curriculum tests
This commit is contained in:
Oliver Eyton-Williams
2021-12-06 20:02:49 +01:00
committed by GitHub
parent 8372623f69
commit a23a47750b
3 changed files with 17 additions and 12 deletions

View File

@ -86,7 +86,8 @@ export function* executeChallengeSaga({ payload }) {
const protect = isLoopProtected(challengeMeta);
const buildData = yield buildChallengeData(challengeData, {
preview: false,
protect
protect,
usesTestRunner: true
});
const document = yield getContext('document');
const testRunner = yield call(

View File

@ -138,12 +138,13 @@ async function getDOMTestRunner(buildData, { proxyLogger }, document) {
runTestInTestFrame(document, testString, testTimeout);
}
export function buildDOMChallenge({
challengeFiles,
required = [],
template = ''
}) {
const finalRequires = [...globalRequires, ...required, ...frameRunner];
export function buildDOMChallenge(
{ challengeFiles, required = [], template = '' },
{ usesTestRunner } = { usesTestRunner: false }
) {
const finalRequires = [...globalRequires, ...required];
if (usesTestRunner) finalRequires.push(...frameRunner);
const loadEnzyme = challengeFiles.some(
challengeFile => challengeFile.ext === 'jsx'
);

View File

@ -570,11 +570,14 @@ async function createTestRunner(
challengeFile.editableContents = solutionFile.editableContents;
});
const { build, sources, loadEnzyme } = await buildChallenge({
challengeFiles,
required,
template
});
const { build, sources, loadEnzyme } = await buildChallenge(
{
challengeFiles,
required,
template
},
{ usesTestRunner: true }
);
const code = {
contents: sources.index,