diff --git a/js/tests/test.mjs b/js/tests/test.mjs index 85ef5646..62c00752 100644 --- a/js/tests/test.mjs +++ b/js/tests/test.mjs @@ -3,6 +3,7 @@ import { join as joinPath, dirname, extname } from 'path' import { readFile, writeFile } from 'fs/promises' import { deepStrictEqual } from 'assert' import { fileURLToPath } from 'url' +import { tmpdir } from 'os' import http from 'http' import fs from 'fs' @@ -48,14 +49,9 @@ const eq = (a, b) => { const [solutionPath, name] = process.argv.slice(2) const tools = { eq, fail, wait, randStr, between, upperFirst } -const cleanup = (exitCode = 0) => { - if (!tools.browser) process.exit(exitCode) - tools.server.close() - return tools.browser.close().finally(() => process.exit(exitCode)) -} const fatal = (...args) => { console.error(...args) - return cleanup(1) + process.exit(1) } solutionPath || fatal('missing solution-path, usage:\nnode test solution-path exercise-name') @@ -119,7 +115,7 @@ const runInlineTests = async ({ json }) => { console.log = (...args) => logs.push(args) const die = (...args) => { logs.forEach((logArgs) => console.info(...logArgs)) - return fatal(...args) + fatal(...args) } const solution = await loadAndSanitizeSolution() @@ -189,12 +185,11 @@ const runTests = async ({ url, path, code }) => { } } catch (err) { console.info(`test #${i+1} failed:\n${t.toString()}\n`) - return fatal(stackFmt(err, url)) + fatal(stackFmt(err, url)) } finally { clearTimeout(timeout) } } - cleanup(0) console.info(`${name} passed (${tests.length} tests)`) } @@ -303,12 +298,12 @@ const main = async () => { .replace(inject.trim(), "") .trim()}\n${testCode.trim()}\n` - // write to file and read file instead ? - const b64 = Buffer.from(combined).toString("base64") - const url = `data:text/javascript;base64,${b64}` + const url = `${tmpdir()}/${name}.mjs` + await writeFile(url, combined) return runTests({ path, code, url }) } -main().catch(err => { - fatal(err?.stack || Error('').stack) -}) +main().then( + () => process.exit(0), + err => fatal(err?.stack || Error('').stack), +) diff --git a/js/tests/verydisco-forever_test.mjs b/js/tests/verydisco-forever_test.mjs index d64e7f31..cb2c59f2 100644 --- a/js/tests/verydisco-forever_test.mjs +++ b/js/tests/verydisco-forever_test.mjs @@ -1,6 +1,4 @@ -import { readFile, mkdir } from 'fs/promises' -import { join, resolve } from 'path' -import { tmpdir } from 'os' +import { readFile } from 'fs/promises' import { promisify } from 'util' import * as cp from 'child_process' diff --git a/subjects/select-and-style-dom/README.md b/subjects/select-and-style-dom/README.md index abbfd62a..c8e050a4 100644 --- a/subjects/select-and-style-dom/README.md +++ b/subjects/select-and-style-dom/README.md @@ -4,7 +4,6 @@ We provide you with some content to get started smoothly, check it out! -- Video [Link a CSS stylesheet to your HTML file](https://www.youtube.com/watch?v=e7G-KhaqTjs&list=PLHyAJ_GrRtf979iZZ1N3qYMfsPj9PCCrF&index=3) - Video [CSS - Style with type selectors](https://www.youtube.com/watch?v=q0ur7YWBzhs&list=PLHyAJ_GrRtf979iZZ1N3qYMfsPj9PCCrF&index=4) - Video [HTML/CSS - Set & style with ID selector](https://www.youtube.com/watch?v=3b3MiY-MR-Y&list=PLHyAJ_GrRtf979iZZ1N3qYMfsPj9PCCrF&index=5) @@ -56,13 +55,41 @@ Set the `background-color` of the HTML element with the `id` `"block-1"`: } ``` +#### How to submit + +This exercise must be submited as a JS file, thankfully, javascript allows you to write `CSS` ! + +Here is how you would submit the `CSS` sample from above in the editor: + +```js +document.documentElement.innerHTML = ` + + + + +
hello
+ +` +``` + +> Make sure the css is between `