@sharadox/vitest-configuration-web-library 0.2.0 → 0.2.1-development.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  What changed in each version of `@sharadox/vitest-configuration-web-library`, newest first.
4
4
 
5
+ ## 0.2.1
6
+
7
+ happy-dom projects get a setup file (browser-animation): a cancelled animation's finished promise rejects as handled, as in browsers, so motion 14 (which animates natively) doesn't fail tests with unhandled rejections.
8
+
5
9
  ## 0.2.0
6
10
 
7
11
  style-web-library's Sass helpers (`style-helper`) are on the Sass load path, so `@use "style-helper"` works in every library, test and site.
package/README.md CHANGED
@@ -40,18 +40,19 @@ Run with `vitest run --coverage` so the thresholds are enforced.
40
40
 
41
41
  ## API
42
42
 
43
- | Import | Export | Description |
44
- | -------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------ |
45
- | `…/library-test` | `defineLibraryTest(options)` | Library configuration, code in `source/` |
46
- | `…/library-test` | `defineProjectTest(folder, options)` | The same for any code folder |
47
- | `…/application-test` | `defineApplicationTest(options)` | Next.js application: code in `src/`, `happy-dom` and React by default, `src/app/**` left to end-to-end tests |
48
- | `…/package-name` | `readPackageName(root)` | The `name` in `<root>/package.json` |
49
- | `…/coverage` | `FULL_COVERAGE`, `NOT_MEASURED` | The thresholds, and the files never measured (tests, `type.ts`, fixtures, `entry/`) |
43
+ | Import | Export | Description |
44
+ | --------------------- | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------- |
45
+ | `…/library-test` | `defineLibraryTest(options)` | Library configuration, code in `source/` |
46
+ | `…/library-test` | `defineProjectTest(folder, options)` | The same for any code folder |
47
+ | `…/application-test` | `defineApplicationTest(options)` | Next.js application: code in `src/`, `happy-dom` and React by default, `src/app/**` left to end-to-end tests |
48
+ | `…/package-name` | `readPackageName(root)` | The `name` in `<root>/package.json` |
49
+ | `…/coverage` | `FULL_COVERAGE`, `NOT_MEASURED` | The thresholds, and the files never measured (tests, `type.ts`, fixtures, `entry/`) |
50
+ | `…/browser-animation` | (a setup file) | A cancelled animation's `finished` rejection is handled, as in browsers (motion cancels animations all the time) |
50
51
 
51
52
  `options`:
52
53
 
53
54
  - `root`: the project folder URL (required).
54
- - `environment`: `"node"` or `"happy-dom"`.
55
+ - `environment`: `"node"` or `"happy-dom"` (which also gets the `browser-animation` setup file).
55
56
  - `react`: boolean.
56
57
  - `coverage`: per-measure thresholds that override 100.
57
58
 
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/browser-animation/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ // A file that runs in node inside a browser-like project has no animations: nothing to do.
2
+ const prototype = globalThis.Animation?.prototype;
3
+ if (prototype) {
4
+ const cancel = prototype.cancel;
5
+ prototype.cancel = function () {
6
+ this.finished.catch(() => { });
7
+ cancel.call(this);
8
+ };
9
+ }
10
+ export {};
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/browser-animation/index.ts"],"names":[],"mappings":"AAeA,2FAA2F;AAC3F,MAAM,SAAS,GAAI,UAAkE,CAAC,SAAS,EAAE,SAAS,CAAC;AAC3G,IAAI,SAAS,EAAE,CAAC;IACd,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAChC,SAAS,CAAC,MAAM,GAAG;QACjB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/library-test/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8DAA8D,CAAC;AAOhG;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,EAAE,IAAI,EAAE,WAAoB,EAAE,KAAK,EAAE,SAAiB,EAAE,QAAQ,EAAE,EAAE,WAAW,GAC9E,cAAc,CA0BhB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAEtE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/library-test/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8DAA8D,CAAC;AAYhG;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,EAAE,IAAI,EAAE,WAAoB,EAAE,KAAK,EAAE,SAAiB,EAAE,QAAQ,EAAE,EAAE,WAAW,GAC9E,cAAc,CA2BhB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAEtE"}
@@ -4,6 +4,8 @@ import { FULL_COVERAGE, NOT_MEASURED } from "@sharadox/vitest-configuration-web-
4
4
  import { readPackageName } from "@sharadox/vitest-configuration-web-library/package-name";
5
5
  /** Where style-web-library's Sass helpers are, from the project's root. */
6
6
  const STYLE_HELPER_PATH = "node_modules/@sharadox/style-web-library/distribution/";
7
+ /** The setup file browser-like tests get, beside this file (TypeScript in source, JavaScript once built). */
8
+ const BROWSER_ANIMATION = fileURLToPath(import.meta.url.replace(/library-test\/index\.(\w+)$/, "browser-animation/index.$1"));
7
9
  const escape = (text) => text.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
8
10
  /**
9
11
  * Builds the Vitest configuration of a project whose code lives in `folder` (`source` for libraries, `src` for
@@ -21,6 +23,7 @@ export function defineProjectTest(folder, { root, environment = "node", react: w
21
23
  css: { preprocessorOptions: { scss: { loadPaths: [code, fileURLToPath(new URL(STYLE_HELPER_PATH, root))] } } },
22
24
  test: {
23
25
  environment,
26
+ ...(environment === "happy-dom" ? { setupFiles: [BROWSER_ANIMATION] } : {}),
24
27
  ...(withReact ? { css: { modules: { classNameStrategy: "non-scoped" } } } : {}),
25
28
  include: [`${folder}/**/?(*-)unit-test.{ts,tsx}`],
26
29
  exclude: ["**/node_modules/**", "**/test-fixture/**"],
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/library-test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,sBAAsB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,MAAM,yDAAyD,CAAC;AAG1F,2EAA2E;AAC3E,MAAM,iBAAiB,GAAG,wDAAwD,CAAC;AAEnF,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;AAE9E;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAc,EACd,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,KAAK,EAAE,QAAQ,EAAe;IAE/E,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,GAAG,MAAM,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IACxD,OAAO;QACL,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE;QACnC,kGAAkG;QACl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,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE;QAC9G,IAAI,EAAE;YACJ,WAAW;YACX,GAAG,CAAC,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3E,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,iBAAiB,EAAE,YAAqB,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACxF,OAAO,EAAE,CAAC,GAAG,MAAM,6BAA6B,CAAC;YACjD,OAAO,EAAE,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;YACrD,6GAA6G;YAC7G,oDAAoD;YACpD,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,aAAa,CAAC,EAAE,EAAE;YAC7C,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,kCAAkC,CAAC,EAAE;YACrE,QAAQ,EAAE;gBACR,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,CAAC,GAAG,MAAM,gBAAgB,CAAC;gBACpC,OAAO,EAAE,CAAC,GAAG,YAAY,CAAC;gBAC1B,UAAU,EAAE,EAAE,GAAG,aAAa,EAAE,GAAG,QAAQ,EAAE;aAC9C;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAoB;IACpD,OAAO,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC"}
package/llms.txt CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > Shared Vitest configs: package self-imports resolve to source, standard test-file patterns, optional React/happy-dom, 100% coverage thresholds.
4
4
 
5
- - `defineLibraryTest({ root: new URL("./", import.meta.url), environment?: "node" | "happy-dom", react?: boolean, coverage?: { branches?: number, ... } })` from `@sharadox/vitest-configuration-web-library/library-test` (code in source/).
5
+ - `defineLibraryTest({ root: new URL("./", import.meta.url), environment?: "node" | "happy-dom", react?: boolean, coverage?: { branches?: number, ... } })` from `@sharadox/vitest-configuration-web-library/library-test` (code in source/). happy-dom projects get the setup file `…/browser-animation`: a cancelled animation's finished promise rejects as handled, as in browsers.
6
6
  - `defineApplicationTest({ root })` from `…/application-test` (code in src/, happy-dom + React default, src/app/** excluded from coverage).
7
7
  - Tests: source/**/?(*-)unit-test.{ts,tsx}; benchmarks: ?(*-)benchmark-test; test-fixture/ skipped.
8
8
  - Coverage: v8, thresholds 100 for statements/branches/functions/lines; run `vitest run --coverage`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sharadox/vitest-configuration-web-library",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-development.26",
4
4
  "description": "Shared Vitest configurations for Sharadox libraries and applications: self-imports by package name, test file patterns, React and Sass support, and 100% coverage thresholds.",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN LICENCA.md",
@@ -49,25 +49,26 @@
49
49
  "homepage": "https://github.com/Sharadox/vitest-configuration-web-library#readme",
50
50
  "devDependencies": {
51
51
  "@eslint/js": "^9.39.5",
52
- "@types/node": "^24.19.2",
53
- "@vitest/coverage-v8": "^5.1.0",
52
+ "@types/node": "^26.6.6",
53
+ "@vitest/coverage-v8": "^5.1.1",
54
54
  "eslint": "9.39.5",
55
55
  "eslint-config-prettier": "^10.1.8",
56
+ "happy-dom": "^21.0.4",
56
57
  "husky": "^9.1.7",
57
- "lint-staged": "^17.6.0",
58
- "prettier": "^3.9.10",
59
- "turbo": "^2.11.10",
58
+ "lint-staged": "^17.6.2",
59
+ "prettier": "^3.10.1",
60
+ "turbo": "^2.11.13",
60
61
  "typedoc": "^0.28.20",
61
62
  "typescript": "6.0.3",
62
- "typescript-eslint": "^8.72.2",
63
- "vitest": "^5.1.0"
63
+ "typescript-eslint": "^8.73.0",
64
+ "vitest": "^5.1.1"
64
65
  },
65
66
  "dependencies": {
66
67
  "@vitejs/plugin-react": "^6.3.0"
67
68
  },
68
69
  "peerDependencies": {
69
- "vitest": ">=5",
70
- "@vitest/coverage-v8": ">=5"
70
+ "@vitest/coverage-v8": ">=5",
71
+ "vitest": ">=5"
71
72
  },
72
73
  "scripts": {
73
74
  "build": "rm -rf distribution && tsc -p tsconfig.build.json",