vitest 0.0.27 → 0.0.28

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/dist/index.d.ts CHANGED
@@ -19,6 +19,8 @@ declare global {
19
19
  toEqual(expected: any): void;
20
20
  toStrictEqual(expected: any): void;
21
21
  toBe(expected: any): void;
22
+ toMatch(expected: string | RegExp): void;
23
+ toMatchObject(expected: any): void;
22
24
  toContain(item: any): void;
23
25
  toBeTruthy(): void;
24
26
  toBeFalsy(): void;
@@ -27,10 +29,10 @@ declare global {
27
29
  toBeNull(): void;
28
30
  toBeDefined(): void;
29
31
  toBeInstanceOf(c: any): void;
30
- toBeCalledTimes(n: number): void;
31
- toBeCalledOnce(): void;
32
- toBeCalled(): void;
32
+ toHaveBeenCalledTimes(n: number): void;
33
+ toHaveBeenCalledOnce(): void;
33
34
  toHaveBeenCalled(): void;
35
+ toHaveBeenCalledWith(...args: any[]): void;
34
36
  }
35
37
  interface ExpectStatic {
36
38
  addSnapshotSerializer: import('pretty-format').Plugin;
@@ -12,6 +12,15 @@ export function JestChaiExpect() {
12
12
  utils.addMethod(proto, 'toBe', function (expected) {
13
13
  return this.equal(expected);
14
14
  });
15
+ utils.addMethod(proto, 'toMatchObject', function (expected) {
16
+ return this.containSubset(expected);
17
+ });
18
+ utils.addMethod(proto, 'toMatch', function (expected) {
19
+ if (typeof expected === 'string')
20
+ return this.include(expected);
21
+ else
22
+ return this.match(expected);
23
+ });
15
24
  utils.addMethod(proto, 'toContain', function (item) {
16
25
  return this.contain(item);
17
26
  });
@@ -39,17 +48,20 @@ export function JestChaiExpect() {
39
48
  return this.instanceOf(obj);
40
49
  });
41
50
  // mock
42
- utils.addMethod(proto, 'toBeCalledTimes', function (number) {
51
+ utils.addMethod(proto, 'toHaveBeenCalledTimes', function (number) {
43
52
  return this.callCount(number);
44
53
  });
45
- utils.addMethod(proto, 'toBeCalledOnce', function () {
54
+ utils.addMethod(proto, 'toHaveBeenCalledOnce', function () {
46
55
  return this.callCount(1);
47
56
  });
48
- utils.addMethod(proto, 'toBeCalled', function () {
57
+ utils.addMethod(proto, 'toHaveBeenCalled', function () {
49
58
  return this.called;
50
59
  });
51
60
  utils.addMethod(proto, 'toHaveBeenCalled', function () {
52
61
  return this.called;
53
62
  });
63
+ utils.addMethod(proto, 'toHaveBeenCalledWith', function (...args) {
64
+ return this.calledWith(...args);
65
+ });
54
66
  };
55
67
  }
@@ -1,9 +1,11 @@
1
1
  import chai from 'chai';
2
2
  import SinonChai from 'sinon-chai';
3
+ import Subset from 'chai-subset';
3
4
  import { JestChaiExpect } from './jest-expect';
4
5
  import { SnapshotPlugin } from './snapshot';
5
6
  export async function setupChai(config) {
6
7
  chai.use(SinonChai);
7
8
  chai.use(JestChaiExpect());
9
+ chai.use(Subset);
8
10
  chai.use(await SnapshotPlugin(config));
9
11
  }
@@ -3,4 +3,5 @@ if (!process.__vite_node__ || !process.__vitest__)
3
3
  throw new Error('Vitest can only run in vite-node environment, please use the CLI to start the process');
4
4
  const inlineOptions = process.__vite_node__.server.config.test || {};
5
5
  const cliOptions = process.__vitest__.options || {};
6
- await run(Object.assign(Object.assign({}, cliOptions), inlineOptions));
6
+ const options = Object.assign(Object.assign({}, cliOptions), inlineOptions);
7
+ await run(options);
@@ -43,7 +43,12 @@ export class DefaultReporter {
43
43
  return {
44
44
  title: relative(process.cwd(), file.filepath),
45
45
  task: () => {
46
- return new Listr(file.suites.flatMap((suite) => {
46
+ if (file.error)
47
+ throw file.error;
48
+ const suites = file.suites.filter(i => i.tasks.length);
49
+ if (!suites.length)
50
+ throw new Error('No tasks found');
51
+ return new Listr(suites.flatMap((suite) => {
47
52
  if (!suite.name)
48
53
  return createTasksListr(suite.tasks);
49
54
  return [{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "keywords": [
6
6
  "vite",
@@ -44,7 +44,7 @@
44
44
  "lint": "eslint \"{src,test}/**/*.ts\"",
45
45
  "prepublishOnly": "nr build",
46
46
  "release": "bumpp --commit --push --tag && esmo scripts/publish.ts",
47
- "test": "node bin/vitest.mjs --dev",
47
+ "test": "node bin/vitest.mjs --dev -r test/core",
48
48
  "test:update": "nr test -u",
49
49
  "watch": "tsc -p src/tsconfig.json --watch"
50
50
  },
@@ -53,6 +53,7 @@
53
53
  "@types/chai": "^4.2.22",
54
54
  "@types/sinon-chai": "^3.2.6",
55
55
  "chai": "^4.3.4",
56
+ "chai-subset": "^1.6.0",
56
57
  "fast-glob": "^3.2.7",
57
58
  "find-up": "^6.2.0",
58
59
  "jest-snapshot": "^27.4.2",
@@ -67,6 +68,7 @@
67
68
  "devDependencies": {
68
69
  "@antfu/eslint-config": "^0.12.1",
69
70
  "@antfu/ni": "^0.11.0",
71
+ "@types/chai-subset": "^1.3.3",
70
72
  "@types/jsdom": "^16.2.13",
71
73
  "@types/listr": "^0.14.4",
72
74
  "@types/node": "^16.11.11",