diff --git a/packages/independent/snapshot/src/side_effects/snapshot_tests.js b/packages/independent/snapshot/src/side_effects/snapshot_tests.js index d7e6840449..e414c5c1b7 100644 --- a/packages/independent/snapshot/src/side_effects/snapshot_tests.js +++ b/packages/independent/snapshot/src/side_effects/snapshot_tests.js @@ -12,6 +12,11 @@ import { renderSideEffects, renderSmallLink } from "./render_side_effects.js"; * @param {Object} snapshotTestsOptions * @param {string|url} snapshotTestsOptions.outFilePattern * @param {string|url} snapshotTestsOptions.rootDirectoryUrl + * @param {Object} [snapshotTestsOptions.executionEffects] + * @param {boolean} [snapshotTestsOptions.executionEffects.catch=true] + * Any error thrown by test function is detected and added to side effects + * @param {boolean} [snapshotTestsOptions.executionEffects.return=true] + * Test function return value is added to side effects * @param {Object} [snapshotTestsOptions.filesystemActions] * Control what to do when there is a file side effect * "compare", "compare_presence_only", "undo", "ignore" diff --git a/tests/build/new_url_directory/_new_url_directory.test.mjs/0_error/0_error.md b/tests/build/new_url_directory/_new_url_directory.test.mjs/0_error/0_error.md index 6fd82d8a72..7092867f26 100644 --- a/tests/build/new_url_directory/_new_url_directory.test.mjs/0_error/0_error.md +++ b/tests/build/new_url_directory/_new_url_directory.test.mjs/0_error/0_error.md @@ -1,4 +1,4 @@ -# [0_error](../../new_url_directory.test.mjs#L25) +# [0_error](../../new_url_directory.test.mjs#L27) ```js run({ diff --git a/tests/build/new_url_directory/_new_url_directory.test.mjs/1_copy/1_copy.md b/tests/build/new_url_directory/_new_url_directory.test.mjs/1_copy/1_copy.md index 128c799883..73162c805d 100644 --- a/tests/build/new_url_directory/_new_url_directory.test.mjs/1_copy/1_copy.md +++ b/tests/build/new_url_directory/_new_url_directory.test.mjs/1_copy/1_copy.md @@ -1,4 +1,4 @@ -# [1_copy](../../new_url_directory.test.mjs#L29) +# [1_copy](../../new_url_directory.test.mjs#L31) ```js run({ diff --git a/tests/build/new_url_directory/new_url_directory.test.mjs b/tests/build/new_url_directory/new_url_directory.test.mjs index 2bd092f0cc..dba64b95f6 100644 --- a/tests/build/new_url_directory/new_url_directory.test.mjs +++ b/tests/build/new_url_directory/new_url_directory.test.mjs @@ -21,13 +21,17 @@ const run = async ({ directoryReferenceEffect }) => { return executeHtml(`${buildServer.origin}/main.html`); }; -await snapshotBuildTests(import.meta.url, ({ test }) => { - test("0_error", () => - run({ - directoryReferenceEffect: "error", - })); - test("1_copy", () => - run({ - directoryReferenceEffect: "copy", - })); -}); +await snapshotBuildTests( + import.meta.url, + ({ test }) => { + test("0_error", () => + run({ + directoryReferenceEffect: "error", + })); + test("1_copy", () => + run({ + directoryReferenceEffect: "copy", + })); + }, + { executionEffects: { catch: true } }, +); diff --git a/tests/dev_and_build/css_background_url/_css_background_url_build.test.mjs/0_basic/0_basic.md b/tests/dev_and_build/css_background_url/_css_background_url_build.test.mjs/0_basic/0_basic.md index 3f8b2a22a8..6fe8091a20 100644 --- a/tests/dev_and_build/css_background_url/_css_background_url_build.test.mjs/0_basic/0_basic.md +++ b/tests/dev_and_build/css_background_url/_css_background_url_build.test.mjs/0_basic/0_basic.md @@ -1,13 +1,7 @@ -# [0_basic](../../css_background_url_build.test.mjs#L5) +# [0_basic](../../css_background_url_build.test.mjs#L15) ```js -build({ - sourceDirectoryUrl: new URL("./client/", import.meta.url), - buildDirectoryUrl: new URL("./build/", import.meta.url), - entryPoints: { "./main.css": "main.css" }, - bundling: false, - minification: false, -}) +run() ``` # 1/2 write 2 files into "./build/" @@ -17,7 +11,7 @@ see [./build/](./build/) # 2/2 resolve ```js -{} +undefined ``` --- diff --git a/tests/dev_and_build/css_background_url/css_background_url_build.test.mjs b/tests/dev_and_build/css_background_url/css_background_url_build.test.mjs index eedde2a722..6833150ac4 100644 --- a/tests/dev_and_build/css_background_url/css_background_url_build.test.mjs +++ b/tests/dev_and_build/css_background_url/css_background_url_build.test.mjs @@ -1,13 +1,16 @@ import { build } from "@jsenv/core"; import { snapshotBuildTests } from "@jsenv/core/tests/snapshot_build_side_effects.js"; +const run = async () => { + await build({ + sourceDirectoryUrl: new URL("./client/", import.meta.url), + buildDirectoryUrl: new URL("./build/", import.meta.url), + entryPoints: { "./main.css": "main.css" }, + bundling: false, + minification: false, + }); +}; + await snapshotBuildTests(import.meta.url, ({ test }) => { - test("0_basic", () => - build({ - sourceDirectoryUrl: new URL("./client/", import.meta.url), - buildDirectoryUrl: new URL("./build/", import.meta.url), - entryPoints: { "./main.css": "main.css" }, - bundling: false, - minification: false, - })); + test("0_basic", () => run()); }); diff --git a/tests/dev_and_build/errors/css_background_url_not_found/_css_background_url_not_found_build.test.mjs/0_basic/0_basic.md b/tests/dev_and_build/errors/css_background_url_not_found/_css_background_url_not_found_build.test.mjs/0_basic/0_basic.md index f7708a518c..131be3135f 100644 --- a/tests/dev_and_build/errors/css_background_url_not_found/_css_background_url_not_found_build.test.mjs/0_basic/0_basic.md +++ b/tests/dev_and_build/errors/css_background_url_not_found/_css_background_url_not_found_build.test.mjs/0_basic/0_basic.md @@ -1,4 +1,4 @@ -# [0_basic](../../css_background_url_not_found_build.test.mjs#L20) +# [0_basic](../../css_background_url_not_found_build.test.mjs#L22) ```js run() diff --git a/tests/dev_and_build/errors/css_background_url_not_found/css_background_url_not_found_build.test.mjs b/tests/dev_and_build/errors/css_background_url_not_found/css_background_url_not_found_build.test.mjs index 3d143af0b2..6dbfafb5a7 100644 --- a/tests/dev_and_build/errors/css_background_url_not_found/css_background_url_not_found_build.test.mjs +++ b/tests/dev_and_build/errors/css_background_url_not_found/css_background_url_not_found_build.test.mjs @@ -16,6 +16,10 @@ const run = async () => { return executeHtml(`${buildServer.origin}/main.html`); }; -await snapshotBuildTests(import.meta.url, ({ test }) => { - test("0_basic", () => run()); -}); +await snapshotBuildTests( + import.meta.url, + ({ test }) => { + test("0_basic", () => run()); + }, + { executionEffects: { catch: true } }, +); diff --git a/tests/dev_and_build/errors/img_not_found/_img_not_found_build.test.mjs/0_basic/0_basic.md b/tests/dev_and_build/errors/img_not_found/_img_not_found_build.test.mjs/0_basic/0_basic.md index 48abc812e8..e4829a0fe0 100644 --- a/tests/dev_and_build/errors/img_not_found/_img_not_found_build.test.mjs/0_basic/0_basic.md +++ b/tests/dev_and_build/errors/img_not_found/_img_not_found_build.test.mjs/0_basic/0_basic.md @@ -1,4 +1,4 @@ -# [0_basic](../../img_not_found_build.test.mjs#L20) +# [0_basic](../../img_not_found_build.test.mjs#L22) ```js run() diff --git a/tests/dev_and_build/errors/img_not_found/img_not_found_build.test.mjs b/tests/dev_and_build/errors/img_not_found/img_not_found_build.test.mjs index 3d143af0b2..6dbfafb5a7 100644 --- a/tests/dev_and_build/errors/img_not_found/img_not_found_build.test.mjs +++ b/tests/dev_and_build/errors/img_not_found/img_not_found_build.test.mjs @@ -16,6 +16,10 @@ const run = async () => { return executeHtml(`${buildServer.origin}/main.html`); }; -await snapshotBuildTests(import.meta.url, ({ test }) => { - test("0_basic", () => run()); -}); +await snapshotBuildTests( + import.meta.url, + ({ test }) => { + test("0_basic", () => run()); + }, + { executionEffects: { catch: true } }, +); diff --git a/tests/dev_and_build/errors/js_import_meta_url_not_found/_js_import_meta_url_not_found_build.test.mjs/0_basic/0_basic.md b/tests/dev_and_build/errors/js_import_meta_url_not_found/_js_import_meta_url_not_found_build.test.mjs/0_basic/0_basic.md index 3fc2be1a40..b431286139 100644 --- a/tests/dev_and_build/errors/js_import_meta_url_not_found/_js_import_meta_url_not_found_build.test.mjs/0_basic/0_basic.md +++ b/tests/dev_and_build/errors/js_import_meta_url_not_found/_js_import_meta_url_not_found_build.test.mjs/0_basic/0_basic.md @@ -1,4 +1,4 @@ -# [0_basic](../../js_import_meta_url_not_found_build.test.mjs#L20) +# [0_basic](../../js_import_meta_url_not_found_build.test.mjs#L22) ```js run() diff --git a/tests/dev_and_build/errors/js_import_meta_url_not_found/js_import_meta_url_not_found_build.test.mjs b/tests/dev_and_build/errors/js_import_meta_url_not_found/js_import_meta_url_not_found_build.test.mjs index 3d143af0b2..ec4a886cab 100644 --- a/tests/dev_and_build/errors/js_import_meta_url_not_found/js_import_meta_url_not_found_build.test.mjs +++ b/tests/dev_and_build/errors/js_import_meta_url_not_found/js_import_meta_url_not_found_build.test.mjs @@ -16,6 +16,12 @@ const run = async () => { return executeHtml(`${buildServer.origin}/main.html`); }; -await snapshotBuildTests(import.meta.url, ({ test }) => { - test("0_basic", () => run()); -}); +await snapshotBuildTests( + import.meta.url, + ({ test }) => { + test("0_basic", () => run()); + }, + { + executionEffects: { catch: true }, + }, +); diff --git a/tests/dev_and_build/errors/js_import_not_found/_js_import_not_found_build.test.mjs/0_basic/0_basic.md b/tests/dev_and_build/errors/js_import_not_found/_js_import_not_found_build.test.mjs/0_basic/0_basic.md index 6829e6c47c..4e9720947d 100644 --- a/tests/dev_and_build/errors/js_import_not_found/_js_import_not_found_build.test.mjs/0_basic/0_basic.md +++ b/tests/dev_and_build/errors/js_import_not_found/_js_import_not_found_build.test.mjs/0_basic/0_basic.md @@ -1,4 +1,4 @@ -# [0_basic](../../js_import_not_found_build.test.mjs#L20) +# [0_basic](../../js_import_not_found_build.test.mjs#L22) ```js run() diff --git a/tests/dev_and_build/errors/js_import_not_found/js_import_not_found_build.test.mjs b/tests/dev_and_build/errors/js_import_not_found/js_import_not_found_build.test.mjs index 3d143af0b2..ec4a886cab 100644 --- a/tests/dev_and_build/errors/js_import_not_found/js_import_not_found_build.test.mjs +++ b/tests/dev_and_build/errors/js_import_not_found/js_import_not_found_build.test.mjs @@ -16,6 +16,12 @@ const run = async () => { return executeHtml(`${buildServer.origin}/main.html`); }; -await snapshotBuildTests(import.meta.url, ({ test }) => { - test("0_basic", () => run()); -}); +await snapshotBuildTests( + import.meta.url, + ({ test }) => { + test("0_basic", () => run()); + }, + { + executionEffects: { catch: true }, + }, +);