twd-js 1.7.2 → 1.7.3

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.
Files changed (59) hide show
  1. package/README.md +26 -4
  2. package/dist/asserts/index.d.ts +2 -0
  3. package/dist/bundled.d.ts +1 -1
  4. package/dist/bundled.es.js +8 -4
  5. package/dist/cli.js +11 -11
  6. package/dist/commands/mockBridge.d.ts +117 -0
  7. package/dist/commands/url.d.ts +33 -0
  8. package/dist/commands/viewport.d.ts +2 -0
  9. package/dist/commands/visit.d.ts +1 -0
  10. package/dist/constants/version.d.ts +1 -0
  11. package/dist/global.d.ts +20 -0
  12. package/dist/index.cjs.js +26 -26
  13. package/dist/index.d.ts +8 -664
  14. package/dist/index.es.js +540 -525
  15. package/dist/initializers/initSidebar.d.ts +29 -0
  16. package/dist/initializers/initTests.d.ts +36 -0
  17. package/dist/mock-sw.js +1 -1
  18. package/dist/plugin/removeMockServiceWorker.d.ts +18 -0
  19. package/dist/plugin/twdHmr.d.ts +45 -0
  20. package/dist/proxies/domMessage.d.ts +1 -0
  21. package/dist/proxies/eventsMessage.d.ts +1 -0
  22. package/dist/proxies/screenDom.d.ts +45 -0
  23. package/dist/proxies/userEvent.d.ts +4 -0
  24. package/dist/runner-ci.d.ts +12 -28
  25. package/dist/runner.d.ts +52 -63
  26. package/dist/twd-types.d.ts +120 -0
  27. package/dist/twd.d.ts +291 -0
  28. package/dist/ui/ClosedSidebar.d.ts +6 -0
  29. package/dist/ui/Icons/BaseIcon.d.ts +7 -0
  30. package/dist/ui/Icons/ChevronDown.d.ts +2 -0
  31. package/dist/ui/Icons/ChevronRight.d.ts +2 -0
  32. package/dist/ui/Icons/Loader.d.ts +2 -0
  33. package/dist/ui/Icons/MockRequestIcon.d.ts +2 -0
  34. package/dist/ui/Icons/Play.d.ts +2 -0
  35. package/dist/ui/LogItem.d.ts +6 -0
  36. package/dist/ui/MockRulesButton.d.ts +1 -0
  37. package/dist/ui/MockedComponent.d.ts +6 -0
  38. package/dist/ui/SearchInput.d.ts +6 -0
  39. package/dist/ui/SkipOnlyName.d.ts +8 -0
  40. package/dist/ui/TWDSidebar.d.ts +20 -0
  41. package/dist/ui/TestList.d.ts +8 -0
  42. package/dist/ui/TestListItem.d.ts +19 -0
  43. package/dist/ui/componentMocks.d.ts +3 -0
  44. package/dist/ui/hooks/useLayout.d.ts +6 -0
  45. package/dist/ui/index.d.ts +1 -0
  46. package/dist/ui/utils/buildTreeFromHandlers.d.ts +16 -0
  47. package/dist/ui/utils/chaiErrorFormat.d.ts +22 -0
  48. package/dist/ui/utils/filterTree.d.ts +2 -0
  49. package/dist/ui/utils/formatLogs.d.ts +30 -0
  50. package/dist/ui/utils/screenReaderMessages.d.ts +9 -0
  51. package/dist/ui/utils/styles.d.ts +7 -0
  52. package/dist/ui/utils/theme.d.ts +74 -0
  53. package/dist/ui.d.ts +2 -10
  54. package/dist/utils/assertionMessage.d.ts +1 -0
  55. package/dist/utils/log.d.ts +1 -0
  56. package/dist/utils/wait.d.ts +3 -0
  57. package/dist/utils/waitFor.d.ts +2 -0
  58. package/dist/vite-plugin.d.ts +2 -67
  59. package/package.json +31 -7
@@ -1,67 +1,2 @@
1
- import { Plugin as Plugin_2 } from 'vite';
2
-
3
- /**
4
- * Vite plugin to remove the mock service worker file from the build output.
5
- * This is useful for production builds where you don't want the mock service worker to be included.
6
- *
7
- * @example
8
- * ```ts
9
- * import { removeMockServiceWorker } from 'twd-js';
10
- *
11
- * export default defineConfig({
12
- * plugins: [
13
- * // ... other plugins
14
- * removeMockServiceWorker()
15
- * ]
16
- * });
17
- * ```
18
- */
19
- export declare function removeMockServiceWorker(): Plugin_2;
20
-
21
- /**
22
- * Vite plugin to handle HMR for TWD test files.
23
- * When a TWD test file is updated, it forces a full page reload to prevent
24
- * duplicate test entries that occur when HMR reloads test modules.
25
- *
26
- * This plugin only runs in development mode (serve) and does not affect Vitest test runs.
27
- *
28
- * @param options - Configuration options for the plugin
29
- * @example
30
- * ```ts
31
- * import { twdHmr } from 'twd-js/vite-plugin';
32
- *
33
- * export default defineConfig({
34
- * plugins: [
35
- * // ... other plugins
36
- * twdHmr() // Uses default pattern: .twd.test.ts
37
- * ]
38
- * });
39
- * ```
40
- * @example
41
- * ```ts
42
- * // Custom pattern
43
- * twdHmr({ testFilePattern: '.twd.test.tsx' })
44
- * ```
45
- * @example
46
- * ```ts
47
- * // Custom function
48
- * twdHmr({
49
- * testFilePattern: (file) => file.includes('.twd.test.')
50
- * })
51
- * ```
52
- */
53
- export declare function twdHmr(options?: TwdHmrOptions): Plugin_2;
54
-
55
- /**
56
- * Options for the TWD HMR plugin.
57
- */
58
- export declare interface TwdHmrOptions {
59
- /**
60
- * Pattern to match test files. Defaults to `.twd.test.ts`.
61
- * Can be a string (checked with `endsWith`) or a function that returns a boolean.
62
- * @default ".twd.test.ts"
63
- */
64
- testFilePattern?: string | ((file: string) => boolean);
65
- }
66
-
67
- export { }
1
+ export { removeMockServiceWorker } from './plugin/removeMockServiceWorker';
2
+ export { twdHmr, type TwdHmrOptions } from './plugin/twdHmr';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "twd-js",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "description": "Test While Developing (TWD) - in-browser testing",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -64,6 +64,11 @@
64
64
  "build": "vite build && vite build -c vite.sw.config.js && NODE_ENV=production vite build -c vite.bundle.config.ts && cp src/cli/installsw.js dist/cli.js",
65
65
  "test": "vitest",
66
66
  "test:ci": "vitest --run --coverage",
67
+ "lint": "eslint src",
68
+ "lint:fix": "eslint src --fix",
69
+ "format": "prettier --write \"src/**/*.{ts,tsx,js,json,md}\"",
70
+ "format:check": "prettier --check \"src/**/*.{ts,tsx,js,json,md}\"",
71
+ "check:only": "scripts/check-only-tests.sh",
67
72
  "conventional-changelog": "conventional-changelog -i CHANGELOG.md",
68
73
  "dev": "vite",
69
74
  "docs:dev": "vitepress dev docs",
@@ -72,27 +77,46 @@
72
77
  "copy:mock-sw": "cp dist/mock-sw.js examples/twd-test-app/public/mock-sw.js && cp dist/mock-sw.js examples/tutorial-example/public/mock-sw.js && cp dist/mock-sw.js examples/vue-twd-example/public/mock-sw.js",
73
78
  "copy:dist:vue-twd-example": "cp -r dist examples/vue-twd-example/src",
74
79
  "copy:dist:tutorial-example": "cp -r dist examples/tutorial-example/src",
75
- "copy:dist:examples": "npm run copy:dist:vue-twd-example && npm run copy:dist:tutorial-example"
80
+ "copy:dist:examples": "npm run copy:dist:vue-twd-example && npm run copy:dist:tutorial-example",
81
+ "prepare": "husky"
82
+ },
83
+ "lint-staged": {
84
+ "src/**/*.{ts,tsx}": [
85
+ "eslint --fix",
86
+ "prettier --write"
87
+ ],
88
+ "src/**/*.{json,md}": [
89
+ "prettier --write"
90
+ ]
76
91
  },
77
92
  "peerDependencies": {
78
93
  "react": ">=17.0.0",
79
94
  "react-dom": ">=17.0.0"
80
95
  },
81
96
  "devDependencies": {
97
+ "@eslint/js": "^9.39.4",
82
98
  "@preact/preset-vite": "^2.10.5",
83
99
  "@testing-library/jest-dom": "^6.9.1",
84
100
  "@testing-library/react": "^16.3.2",
85
101
  "@types/react": "^19.2.14",
86
102
  "@types/react-dom": "^19.2.3",
87
103
  "@vitejs/plugin-react": "^6.0.1",
88
- "@vitest/coverage-v8": "^4.1.4",
104
+ "@vitest/coverage-v8": "^4.1.5",
105
+ "@vitest/eslint-plugin": "^1.6.16",
89
106
  "conventional-changelog": "^7.2.0",
90
- "jsdom": "^29.0.2",
107
+ "eslint": "^9.39.4",
108
+ "eslint-config-prettier": "^10.1.8",
109
+ "globals": "^17.6.0",
110
+ "husky": "^9.1.7",
111
+ "jsdom": "^29.1.1",
112
+ "lint-staged": "^16.4.0",
113
+ "prettier": "^3.8.3",
91
114
  "typescript": "~5.9.3",
92
- "vite": "^8.0.8",
93
- "vite-plugin-dts": "^4.5.4",
115
+ "typescript-eslint": "^8.59.1",
116
+ "vite": "^8.0.10",
117
+ "vite-plugin-dts": "^5.0.0",
94
118
  "vitepress": "^2.0.0-alpha.12",
95
- "vitest": "^4.1.4"
119
+ "vitest": "^4.1.5"
96
120
  },
97
121
  "keywords": [
98
122
  "testing",