fix(client): get jquery from cdn (#44421)

* fix: ensures jquery exists for those challenges

For tests frame-runner.js imports jquery, but jquery challenges always
need it

* Revert "Revert "fix: only include frame-runner when running tests (#44337)" (#44419)"

This reverts commit c19bf504b8.
This commit is contained in:
Oliver Eyton-Williams
2022-01-07 11:42:27 +01:00
committed by GitHub
parent fee0ac3846
commit 87f5cff3cd
4 changed files with 20 additions and 12 deletions

View File

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

View File

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

View File

@ -8,6 +8,9 @@
"required": [ "required": [
{ {
"link": "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" "link": "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css"
},
{
"src": "https://code.jquery.com/jquery-3.6.0.min.js"
} }
], ],
"superBlock": "front-end-development-libraries", "superBlock": "front-end-development-libraries",

View File

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