Skip to content

Commit e98e10f

Browse files
committed
chore(repo): migration from ava to vitest. phase 1
1 parent 8a6e5a9 commit e98e10f

39 files changed

Lines changed: 841 additions & 46 deletions

File tree

.config/vitest.config.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import path from 'node:path';
33

44
export default defineConfig({
55
test: {
6+
globals: true,
7+
include: ['**/*.{test,spec}.?(c|m)[jt]s?(x)', 'test/test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
68
// Store snapshots next to each test in a .snapshots folder
79
resolveSnapshotPath: (testPath, snapExt) =>
810
path.join(path.dirname(testPath), '.snapshots', path.basename(testPath) + snapExt)

packages/beep/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
2222
"ci:lint": "pnpm lint",
2323
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
24-
"ci:test": "ava --verbose",
24+
"ci:test": "pnpm test -- --reporter=verbose",
2525
"release": "pnpm --workspace-root package:release $(pwd)",
26-
"test": "ava"
26+
"test": "vitest --config ../../.config/vitest.config.mts run"
2727
},
2828
"files": [
2929
"lib/",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`pass 1`] = `
4+
"
5+
fixtures/pass.js → output/bundle.js...
6+
created output/bundle.js in <time>ms"
7+
`;

packages/beep/test/test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const test = require('ava');
21
const execa = require('execa');
32

3+
const test = require('../../../util/vitest-ava-compat');
4+
45
const options = { cwd: __dirname };
56

67
test('pass', async (t) => {

packages/buble/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
2929
"ci:lint": "pnpm build && pnpm lint",
3030
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
31-
"ci:test": "pnpm test -- --verbose",
31+
"ci:test": "pnpm test -- --reporter=verbose",
3232
"prebuild": "del-cli dist",
3333
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
3434
"prerelease": "pnpm build",
3535
"pretest": "pnpm build",
3636
"release": "pnpm --workspace-root package:release $(pwd)",
37-
"test": "ava",
37+
"test": "vitest --config ../../.config/vitest.config.mts run",
3838
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
3939
},
4040
"files": [

packages/buble/test/test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const test = require('ava');
21
const rollup = require('rollup');
32

3+
const test = require('../../../util/vitest-ava-compat');
4+
45
const buble = require('..');
56

67
process.chdir(__dirname);

packages/data-uri/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
2929
"ci:lint": "pnpm build && pnpm lint",
3030
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
31-
"ci:test": "pnpm test -- --verbose",
31+
"ci:test": "pnpm test -- --reporter=verbose",
3232
"prebuild": "del-cli dist",
3333
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
3434
"prerelease": "pnpm build",
3535
"pretest": "pnpm build --sourcemap",
3636
"release": "pnpm --workspace-root package:release $(pwd)",
37-
"test": "ava",
37+
"test": "vitest --config ../../.config/vitest.config.mts run",
3838
"test:ts": "tsc --noEmit"
3939
},
4040
"files": [
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`bad json 1`] = `
4+
{
5+
"code": "PLUGIN_ERROR",
6+
"plugin": "dataUri",
7+
"pluginCode": "DU$JSON",
8+
}
9+
`;
10+
11+
exports[`base64 1`] = `
12+
{
13+
"batman": "true",
14+
}
15+
`;
16+
17+
exports[`base64 2`] = `
18+
"'use strict';
19+
20+
const batman = "true";
21+
var batman$1 = {
22+
batman: batman
23+
};
24+
25+
t.truthy(batman$1.batman);
26+
t.snapshot(batman$1);
27+
"
28+
`;
29+
30+
exports[`import 1`] = `true`;
31+
32+
exports[`import 2`] = `
33+
"'use strict';
34+
35+
t.truthy(true);
36+
37+
const batman = true;
38+
39+
t.snapshot(batman);
40+
"
41+
`;
42+
43+
exports[`json 1`] = `
44+
{
45+
"batman": "true",
46+
}
47+
`;
48+
49+
exports[`json 2`] = `
50+
"'use strict';
51+
52+
const batman = "true";
53+
var batman$1 = {
54+
batman: batman
55+
};
56+
57+
t.truthy(batman$1.batman);
58+
t.snapshot(batman$1);
59+
"
60+
`;
61+
62+
exports[`works as CJS plugin 1`] = `
63+
{
64+
"batman": "true",
65+
}
66+
`;
67+
68+
exports[`works as CJS plugin 2`] = `
69+
"'use strict';
70+
71+
const batman = "true";
72+
var batman$1 = {
73+
batman: batman
74+
};
75+
76+
t.truthy(batman$1.batman);
77+
t.snapshot(batman$1);
78+
"
79+
`;

packages/data-uri/test/test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createRequire } from 'module';
22
import { fileURLToPath } from 'url';
33

4-
import test from 'ava';
4+
import test from '../../../util/vitest-ava-compat.js';
55
import { rollup } from 'rollup';
66

77
import dataUri from 'current-package';

packages/dsv/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
2626
"ci:lint": "pnpm build && pnpm lint",
2727
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
28-
"ci:test": "pnpm test -- --verbose",
28+
"ci:test": "pnpm test -- --reporter=verbose",
2929
"prebuild": "del-cli dist",
3030
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
3131
"prerelease": "pnpm build",
3232
"pretest": "pnpm build",
3333
"release": "pnpm --workspace-root package:release $(pwd)",
34-
"test": "ava"
34+
"test": "vitest --config ../../.config/vitest.config.mts run"
3535
},
3636
"files": [
3737
"dist",

0 commit comments

Comments
 (0)