mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-08 12:04:29 -05:00
fix(tools): sync up unit tests with client tests (#57512)
This commit is contained in:
committed by
GitHub
parent
d6530bc3a1
commit
5d5dafbd1e
@@ -93,7 +93,7 @@ function buildSourceMap(challengeFiles: ChallengeFile[]): Source | undefined {
|
||||
return source;
|
||||
}
|
||||
|
||||
const buildFunctions = {
|
||||
export const buildFunctions = {
|
||||
[challengeTypes.js]: buildJSChallenge,
|
||||
[challengeTypes.jsProject]: buildJSChallenge,
|
||||
[challengeTypes.html]: buildDOMChallenge,
|
||||
|
||||
@@ -25,8 +25,9 @@ require('@babel/register')({
|
||||
});
|
||||
const {
|
||||
buildDOMChallenge,
|
||||
buildJSChallenge,
|
||||
buildPythonChallenge
|
||||
buildPythonChallenge,
|
||||
buildChallenge,
|
||||
buildFunctions
|
||||
} = require('../../client/src/templates/Challenges/utils/build');
|
||||
const {
|
||||
WorkerExecutor
|
||||
@@ -407,18 +408,6 @@ function populateTestsForLang({ lang, challenges, meta, superBlocks }) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO(after python PR): simplify pipeline and sync with client.
|
||||
// buildChallengeData should be called and any errors handled.
|
||||
// canBuildChallenge does not need to exist independently.
|
||||
const buildChallenge =
|
||||
{
|
||||
[challengeTypes.js]: buildJSChallenge,
|
||||
[challengeTypes.jsProject]: buildJSChallenge,
|
||||
[challengeTypes.python]: buildPythonChallenge,
|
||||
[challengeTypes.multifilePythonCertProject]:
|
||||
buildPythonChallenge
|
||||
}[challengeType] ?? buildDOMChallenge;
|
||||
|
||||
// The python tests are (currently) slow, so we give them more time.
|
||||
const timePerTest =
|
||||
challengeType === challengeTypes.python ? 10000 : 5000;
|
||||
@@ -563,8 +552,6 @@ async function createTestRunner(
|
||||
buildChallenge,
|
||||
solutionFromNext
|
||||
) {
|
||||
const { required = [], template } = challenge;
|
||||
|
||||
const challengeFiles = replaceChallengeFilesContentsWithSolutions(
|
||||
challenge.challengeFiles,
|
||||
solutionFiles
|
||||
@@ -572,9 +559,8 @@ async function createTestRunner(
|
||||
|
||||
const { build, sources, loadEnzyme } = await buildChallenge(
|
||||
{
|
||||
challengeFiles,
|
||||
required,
|
||||
template
|
||||
...challenge,
|
||||
challengeFiles
|
||||
},
|
||||
{ usesTestRunner: true }
|
||||
);
|
||||
@@ -585,8 +571,10 @@ async function createTestRunner(
|
||||
original: sources.original
|
||||
};
|
||||
|
||||
const runsInBrowser = buildChallenge === buildDOMChallenge;
|
||||
const runsInPythonWorker = buildChallenge === buildPythonChallenge;
|
||||
const buildFunction = buildFunctions[challenge.challengeType];
|
||||
|
||||
const runsInBrowser = buildFunction === buildDOMChallenge;
|
||||
const runsInPythonWorker = buildFunction === buildPythonChallenge;
|
||||
|
||||
const evaluator = await (runsInBrowser
|
||||
? getContextEvaluator(build, sources, code, loadEnzyme)
|
||||
|
||||
Reference in New Issue
Block a user