vitest 0.0.1 → 0.0.6

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/bin/vitest.mjs CHANGED
@@ -3,18 +3,40 @@
3
3
 
4
4
  import { fileURLToPath } from 'url'
5
5
  import { resolve, dirname } from 'path'
6
- import { startAndRun } from 'vite-node'
6
+ import { run } from 'vite-node'
7
7
  import minimist from 'minimist'
8
+ import { findUp } from 'find-up'
8
9
 
9
10
  const argv = minimist(process.argv.slice(2), {
10
- string: ['root'],
11
+ alias: {
12
+ c: 'config',
13
+ },
14
+ string: ['root', 'config'],
15
+ boolean: ['dev'],
11
16
  })
12
17
 
13
18
  const __dirname = dirname(fileURLToPath(import.meta.url))
19
+ const root = resolve(argv.root || process.cwd())
14
20
 
15
- await startAndRun({
16
- root: resolve(argv.root || process.cwd()),
21
+ const configPath = argv.config ? resolve(root, argv.config) : await findUp(['vitest.config.ts', 'vitest.config.js', 'vitest.config.mjs', 'vite.config.ts', 'vite.config.js', 'vite.config.mjs'], { cwd: root })
22
+
23
+ await run({
24
+ root,
17
25
  files: [
18
- resolve(__dirname, '../dist/cli.js'),
26
+ resolve(__dirname, argv.dev ? '../src/cli.ts' : '../dist/cli.js'),
19
27
  ],
28
+ config: configPath,
29
+ defaultConfig: {
30
+ optimizeDeps: {
31
+ exclude: [
32
+ 'vitest',
33
+ ],
34
+ },
35
+ },
36
+ shouldExternalize(id) {
37
+ if (id.includes('/node_modules/vitest/'))
38
+ return false
39
+ else
40
+ return id.includes('/node_modules/')
41
+ },
20
42
  })
package/dist/chai.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export { assert, should, expect } from 'chai';
2
+ declare global {
3
+ namespace Chai {
4
+ interface Assertion {
5
+ toMatchSnapshot(message?: string): Assertion;
6
+ matchSnapshot(message?: string): Assertion;
7
+ }
8
+ interface ExpectStatic {
9
+ addSnapshotSerializer: import('pretty-format').Plugin;
10
+ }
11
+ }
12
+ }
package/dist/chai.js ADDED
@@ -0,0 +1 @@
1
+ export { assert, should, expect } from 'chai';
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { join } from 'path';
1
+ var _a;
2
2
  import minimist from 'minimist';
3
3
  import c from 'picocolors';
4
4
  import { run } from './run';
@@ -7,8 +7,8 @@ const argv = minimist(process.argv.slice(2), {
7
7
  alias: {
8
8
  u: 'update',
9
9
  },
10
- string: ['root'],
11
- boolean: ['update'],
10
+ string: ['root', 'config'],
11
+ boolean: ['update', 'dev'],
12
12
  unknown(name) {
13
13
  if (name[0] === '-') {
14
14
  console.error(c.red(`Unknown argument: ${name}`));
@@ -18,11 +18,11 @@ const argv = minimist(process.argv.slice(2), {
18
18
  return true;
19
19
  },
20
20
  });
21
- // TODO: load config, CLI
22
- run({
23
- rootDir: argv.root || join(process.cwd(), 'test'),
24
- updateSnapshot: argv.update,
25
- });
21
+ // @ts-expect-error
22
+ const server = (_a = process === null || process === void 0 ? void 0 : process.__vite_node__) === null || _a === void 0 ? void 0 : _a.server;
23
+ const viteConfig = (server === null || server === void 0 ? void 0 : server.config) || {};
24
+ const testOptions = viteConfig.test || {};
25
+ await run(Object.assign(Object.assign({}, testOptions), { updateSnapshot: argv.update, rootDir: argv.root || process.cwd() }));
26
26
  function help() {
27
27
  log('Help: finish help');
28
28
  }
@@ -0,0 +1,17 @@
1
+ import { UserConfig } from 'vite';
2
+ import { UserOptions } from './types';
3
+ export interface VitestConfig extends UserConfig {
4
+ /**
5
+ * Options for Vitest
6
+ */
7
+ test?: UserOptions;
8
+ }
9
+ export declare function defineConfig(config: VitestConfig): VitestConfig;
10
+ declare module 'vite' {
11
+ interface UserConfig {
12
+ /**
13
+ * Options for Vitest
14
+ */
15
+ test?: UserOptions;
16
+ }
17
+ }
package/dist/config.js ADDED
@@ -0,0 +1,3 @@
1
+ export function defineConfig(config) {
2
+ return config;
3
+ }
package/dist/index.d.ts CHANGED
@@ -1,14 +1,4 @@
1
1
  export * from './types';
2
2
  export * from './suite';
3
- export { assert, should, expect } from 'chai';
4
- declare global {
5
- namespace Chai {
6
- interface Assertion {
7
- toMatchSnapshot(message?: string): Assertion;
8
- matchSnapshot(message?: string): Assertion;
9
- }
10
- interface ExpectStatic {
11
- addSnapshotSerializer: import('pretty-format').Plugin;
12
- }
13
- }
14
- }
3
+ export * from './config';
4
+ export * from './chai';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './types';
2
2
  export * from './suite';
3
- export { assert, should, expect } from 'chai';
3
+ export * from './config';
4
+ export * from './chai';
package/dist/run.js CHANGED
@@ -76,6 +76,7 @@ export async function run(options = {}) {
76
76
  const files = await fg(options.includes || ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], {
77
77
  absolute: true,
78
78
  cwd: options.rootDir,
79
+ ignore: options.excludes || ['**/node_modules/**', '**/dist/**'],
79
80
  });
80
81
  if (!files.length) {
81
82
  console.error('No test files found');
package/dist/types.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- export interface Options {
2
- rootDir?: string;
1
+ export interface UserOptions {
3
2
  includes?: string[];
4
3
  excludes?: string[];
4
+ }
5
+ export interface Options extends UserOptions {
6
+ rootDir?: string;
5
7
  updateSnapshot?: boolean;
6
8
  }
7
9
  export interface Task {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.1",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "keywords": [],
@@ -17,14 +17,13 @@
17
17
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
18
18
  "exports": {
19
19
  ".": {
20
- "require": "./dist/index.cjs",
21
- "import": "./dist/index.mjs",
20
+ "import": "./dist/index.js",
22
21
  "types": "./dist/index.d.ts"
23
22
  },
24
23
  "./*": "./*"
25
24
  },
26
- "main": "./dist/index.cjs",
27
- "module": "./dist/index.mjs",
25
+ "main": "./dist/index.js",
26
+ "module": "./dist/index.js",
28
27
  "types": "./dist/index.d.ts",
29
28
  "files": [
30
29
  "dist",
@@ -33,10 +32,18 @@
33
32
  "bin": {
34
33
  "vitest": "./bin/vitest.mjs"
35
34
  },
35
+ "scripts": {
36
+ "build": "tsc",
37
+ "watch": "tsc --watch",
38
+ "lint": "eslint \"{src,test}/**/*.ts\"",
39
+ "prepublishOnly": "nr build",
40
+ "release": "bumpp --commit --push --tag && pnpm publish",
41
+ "test": "node bin/vitest.mjs --dev",
42
+ "test:update": "nr test -u"
43
+ },
36
44
  "devDependencies": {
37
45
  "@antfu/eslint-config": "^0.11.1",
38
46
  "@antfu/ni": "^0.11.0",
39
- "@types/chai": "^4.2.22",
40
47
  "@types/minimist": "^1.2.2",
41
48
  "@types/node": "^16.11.11",
42
49
  "bumpp": "^7.1.1",
@@ -47,20 +54,14 @@
47
54
  },
48
55
  "dependencies": {
49
56
  "@jest/test-result": "^27.4.2",
57
+ "@types/chai": "^4.2.22",
50
58
  "chai": "^4.3.4",
51
59
  "fast-glob": "^3.2.7",
60
+ "find-up": "^6.2.0",
52
61
  "jest-snapshot": "^27.4.2",
53
62
  "jest-util": "^27.4.2",
54
63
  "minimist": "^1.2.5",
55
64
  "picocolors": "^1.0.0",
56
- "vite-node": "v0.1.6"
57
- },
58
- "scripts": {
59
- "build": "tsc",
60
- "watch": "tsc --watch",
61
- "lint": "eslint \"{src,test}/**/*.ts\"",
62
- "release": "bumpp --commit --push --tag && pnpm publish",
63
- "test": "npx vite-node src/cli.ts --",
64
- "test:update": "nr test -u"
65
+ "vite-node": "^0.1.9"
65
66
  }
66
- }
67
+ }