vitest 0.0.30 → 0.0.31

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/README.gh.md CHANGED
@@ -46,6 +46,12 @@ describe('suite name', () => {
46
46
  $ npx vitest
47
47
  ```
48
48
 
49
+ ## Examples
50
+
51
+ - [Unit Testing](./test/core)
52
+ - [Vue Component Testing](./test/vue)
53
+ - [React Component Testing](./test/react)
54
+
49
55
  ## Configuration
50
56
 
51
57
  `vitest` will read your root `vite.config.ts` when it present to match with the plugins and setup as your Vite app. If you want to it to have a different configuration for testing, you could either:
@@ -5,3 +5,8 @@ const inlineOptions = process.__vite_node__.server.config.test || {};
5
5
  const cliOptions = process.__vitest__.options || {};
6
6
  const options = Object.assign(Object.assign({}, cliOptions), inlineOptions);
7
7
  await run(options);
8
+ const timer = setTimeout(() => {
9
+ // TODO: warn user and maybe error out
10
+ process.exit();
11
+ }, 500);
12
+ timer.unref();
package/dist/run/index.js CHANGED
@@ -185,7 +185,7 @@ export async function run(config) {
185
185
  snapshotManager.saveSnap();
186
186
  await ((_c = reporter.onFinished) === null || _c === void 0 ? void 0 : _c.call(reporter, ctx));
187
187
  if (config.watch)
188
- startWatcher(ctx);
188
+ await startWatcher(ctx);
189
189
  }
190
190
  export async function startWatcher(ctx) {
191
191
  var _a;
@@ -196,6 +196,7 @@ export async function startWatcher(ctx) {
196
196
  const seen = new Set();
197
197
  const { server, moduleCache } = process.__vite_node__;
198
198
  server.watcher.on('change', async (id) => {
199
+ id = normalizePath(id);
199
200
  getDependencyTests(id, ctx, changedTests, seen);
200
201
  seen.forEach(i => moduleCache.delete(i));
201
202
  seen.clear();
@@ -219,6 +220,14 @@ export async function startWatcher(ctx) {
219
220
  await ((_c = reporter.onWatcherStart) === null || _c === void 0 ? void 0 : _c.call(reporter, ctx));
220
221
  }, 100);
221
222
  });
223
+ // add an empty promise so it never resolves
224
+ await new Promise(() => { });
225
+ }
226
+ function normalizePath(path) {
227
+ const normalized = path.replace(/\\/g, '/');
228
+ if (normalized.startsWith('/'))
229
+ return normalized;
230
+ return `/${normalized}`;
222
231
  }
223
232
  function getDependencyTests(id, ctx, set = new Set(), seen = new Set()) {
224
233
  if (seen.has(id) || set.has(id))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.30",
3
+ "version": "0.0.31",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "keywords": [
6
6
  "vite",
@@ -47,6 +47,7 @@
47
47
  "test": "run-s test:*",
48
48
  "test:core": "node bin/vitest.mjs --dev -r test/core",
49
49
  "test:vue": "node bin/vitest.mjs --dev -r test/vue",
50
+ "test:react": "node bin/vitest.mjs --dev -r test/react",
50
51
  "watch": "tsc -p src/tsconfig.json --watch"
51
52
  },
52
53
  "dependencies": {
@@ -73,23 +74,21 @@
73
74
  "vite": "^2.7.0"
74
75
  },
75
76
  "devDependencies": {
76
- "@antfu/eslint-config": "^0.12.1",
77
+ "@antfu/eslint-config": "^0.12.2",
77
78
  "@antfu/ni": "^0.11.0",
78
79
  "@types/chai-subset": "^1.3.3",
79
80
  "@types/diff": "^5.0.1",
80
81
  "@types/jsdom": "^16.2.13",
81
82
  "@types/listr": "^0.14.4",
82
- "@types/node": "^16.11.11",
83
+ "@types/node": "^16.11.12",
83
84
  "@types/sade": "^1.7.3",
84
85
  "@types/sinon": "^10.0.6",
85
- "@vitejs/plugin-vue": "^1.10.1",
86
86
  "bumpp": "^7.1.1",
87
- "eslint": "^8.4.0",
87
+ "eslint": "^8.4.1",
88
88
  "esno": "^0.12.1",
89
89
  "npm-run-all": "^4.1.5",
90
90
  "rimraf": "^3.0.2",
91
91
  "typescript": "^4.5.2",
92
- "vite": "^2.7.0",
93
- "vue": "^3.2.24"
92
+ "vite": "^2.7.0"
94
93
  }
95
94
  }