Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .config/vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import path from 'node:path';

export default defineConfig({
test: {
// Store snapshots next to each test in a .snapshots folder
// Enable global APIs for CommonJS test files.
globals: true,
// Phase 1 packages use runtime-style test entrypoints.
include: ['test/test.{js,mjs,cjs,ts,mts,cts}'],
// Keep snapshots in the same location used by Ava.
resolveSnapshotPath: (testPath, snapExt) =>
path.join(path.dirname(testPath), '.snapshots', path.basename(testPath) + snapExt)
path.join(path.dirname(testPath), 'snapshots', path.basename(testPath) + snapExt)
},
resolve: {
// Allow importing the current package under test via `~package`
Expand Down
14 changes: 3 additions & 11 deletions packages/beep/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
"ci:lint": "pnpm lint",
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
"ci:test": "ava --verbose",
"ci:test": "pnpm test -- --reporter=verbose",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava"
"test": "vitest --config ../../.config/vitest.config.mts run"
},
"files": [
"lib/",
Expand All @@ -49,13 +49,5 @@
"rollup": "^4.0.0-24",
"strip-ansi": "^7.0.1"
},
"types": "types/index.d.ts",
"ava": {
"files": [
"!**/fixtures/**",
"!**/helpers/**",
"!**/output/**",
"!**/recipes/**"
]
}
"types": "types/index.d.ts"
}
13 changes: 0 additions & 13 deletions packages/beep/test/snapshots/test.js.md

This file was deleted.

Binary file modified packages/beep/test/snapshots/test.js.snap
Binary file not shown.
16 changes: 10 additions & 6 deletions packages/beep/test/test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
const test = require('ava');
const execa = require('execa');

const options = { cwd: __dirname };

test('pass', async (t) => {
test('pass', async () => {
const args = '--config fixtures/pass.config.js'.split(' ');
const { stderr } = await execa('rollup', args, options);
const { default: strip } = await import('strip-ansi');

t.snapshot(strip(stderr.replace(/\d+ms|[\d.]+s/, '<time>ms')));
expect(strip(stderr.replace(/\d+ms|[\d.]+s/, '<time>ms'))).toMatchSnapshot();
});

test('error', async (t) => {
test('error', async () => {
const args = '--config fixtures/error.config.js'.split(' ');
const throws = async () => execa('rollup', args, options);

const { stderr } = await t.throwsAsync(throws);
t.truthy(stderr.indexOf('\x07'));
const error = await throws().then(
() => null,
(caught) => caught
);
expect(error).not.toBeNull();
const { stderr } = error;
expect(stderr.indexOf('\x07')).toBeTruthy();
});
16 changes: 3 additions & 13 deletions packages/buble/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
"ci:lint": "pnpm build && pnpm lint",
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
"ci:test": "pnpm test -- --verbose",
"ci:test": "pnpm test -- --reporter=verbose",
"prebuild": "del-cli dist",
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava",
"test": "vitest --config ../../.config/vitest.config.mts run",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
"files": [
Expand Down Expand Up @@ -73,15 +73,5 @@
"source-map": "^0.7.4",
"typescript": "^4.8.3"
},
"types": "./types/index.d.ts",
"ava": {
"workerThreads": false,
"files": [
"!**/fixtures/**",
"!**/output/**",
"!**/helpers/**",
"!**/recipes/**",
"!**/types.ts"
]
}
"types": "./types/index.d.ts"
}
9 changes: 5 additions & 4 deletions packages/buble/test/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const test = require('ava');
const rollup = require('rollup');

const buble = require('..');
Expand All @@ -22,12 +21,14 @@ function getChunksFromBundle(bundle) {
.then(getChunksFromGenerated);
}

test('transforms files', async (t) => {
test('transforms files', async () => {
const bundle = await rollup.rollup({
input: `${__dirname}/fixtures/basic/main.js`,
plugins: [buble()]
});
const generated = await getChunksFromBundle(bundle);
t.is(generated.length, 1);
t.is(generated[0].code, 'function main () { return 42; }\n\nexport { main as default };\n');
expect(generated.length).toBe(1);
expect(generated[0].code).toBe(
'function main () { return 42; }\n\nexport { main as default };\n'
);
});
16 changes: 3 additions & 13 deletions packages/data-uri/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
"ci:lint": "pnpm build && pnpm lint",
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
"ci:test": "pnpm test -- --verbose",
"ci:test": "pnpm test -- --reporter=verbose",
"prebuild": "del-cli dist",
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build --sourcemap",
"release": "pnpm --workspace-root package:release $(pwd)",
"test": "ava",
"test": "vitest --config ../../.config/vitest.config.mts run",
"test:ts": "tsc --noEmit"
},
"files": [
Expand Down Expand Up @@ -70,15 +70,5 @@
"rollup": "^4.0.0-24",
"typescript": "^4.8.3"
},
"types": "./types/index.d.ts",
"ava": {
"workerThreads": false,
"files": [
"!**/fixtures/**",
"!**/output/**",
"!**/helpers/**",
"!**/recipes/**",
"!**/types.ts"
]
}
"types": "./types/index.d.ts"
}
4 changes: 2 additions & 2 deletions packages/data-uri/test/fixtures/base64.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import batman from 'data:application/json;base64, eyAiYmF0bWFuIjogInRydWUiIH0=';

t.truthy(batman.batman);
t.snapshot(batman);
expect(batman.batman).toBeTruthy();
expect(batman).toMatchSnapshot();
4 changes: 2 additions & 2 deletions packages/data-uri/test/fixtures/import.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'data:text/javascript, t.truthy(true);';
import 'data:text/javascript, expect(true).toBeTruthy();';
import { batman } from 'data:text/javascript, export const batman = true;\nconst joker = false;\nexport default joker;';

t.snapshot(batman);
expect(batman).toMatchSnapshot();
4 changes: 2 additions & 2 deletions packages/data-uri/test/fixtures/json.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import batman from 'data:application/json, { "batman": "true" }';

t.truthy(batman.batman);
t.snapshot(batman);
expect(batman.batman).toBeTruthy();
expect(batman).toMatchSnapshot();
95 changes: 0 additions & 95 deletions packages/data-uri/test/snapshots/test.mjs.md

This file was deleted.

Binary file modified packages/data-uri/test/snapshots/test.mjs.snap
Binary file not shown.
41 changes: 21 additions & 20 deletions packages/data-uri/test/test.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createRequire } from 'module';
import { fileURLToPath } from 'url';

import test from 'ava';
import { test, expect } from 'vitest';
import { rollup } from 'rollup';

import dataUri from 'current-package';
Expand All @@ -11,54 +11,55 @@
const DIRNAME = fileURLToPath(new URL('./fixtures', import.meta.url));
process.chdir(DIRNAME);

test('json', async (t) => {
t.plan(3);
test('json', async () => {
const bundle = await rollup({
input: 'json.js',
plugins: [dataUri()]
});
const { code } = await testBundle(t, bundle);
t.snapshot(code);
const { code } = await testBundle(undefined, bundle);

Check warning on line 19 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v24

Unexpected use of undefined

Check warning on line 19 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v20

Unexpected use of undefined

Check warning on line 19 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v24

Unexpected use of undefined

Check warning on line 19 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v20

Unexpected use of undefined
expect(code).toMatchSnapshot();
});

test('import', async (t) => {
t.plan(3);
test('import', async () => {
const bundle = await rollup({
input: 'import.js',
plugins: [dataUri()]
});
const { code } = await testBundle(t, bundle);
t.snapshot(code);
const { code } = await testBundle(undefined, bundle);

Check warning on line 28 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v24

Unexpected use of undefined

Check warning on line 28 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v20

Unexpected use of undefined

Check warning on line 28 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v24

Unexpected use of undefined

Check warning on line 28 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v20

Unexpected use of undefined
expect(code).toMatchSnapshot();
});

test('bad json', async (t) => {
test('bad json', async () => {
const fn = () =>
rollup({
input: 'bad-json.js',
plugins: [dataUri()]
});
const { code, plugin, pluginCode } = await t.throwsAsync(fn);
t.snapshot({ code, plugin, pluginCode });
const error = await fn().then(
() => null,
(caught) => caught
);
expect(error).not.toBeNull();
const { code, plugin, pluginCode } = error;
expect({ code, plugin, pluginCode }).toMatchSnapshot();
});

test('base64', async (t) => {
t.plan(3);
test('base64', async () => {
const bundle = await rollup({
input: 'base64.js',
plugins: [dataUri()]
});
const { code } = await testBundle(t, bundle);
t.snapshot(code);
const { code } = await testBundle(undefined, bundle);

Check warning on line 52 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v24

Unexpected use of undefined

Check warning on line 52 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v20

Unexpected use of undefined

Check warning on line 52 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v24

Unexpected use of undefined

Check warning on line 52 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v20

Unexpected use of undefined
expect(code).toMatchSnapshot();
});

test('works as CJS plugin', async (t) => {
t.plan(3);
test('works as CJS plugin', async () => {
const require = createRequire(import.meta.url);
const dataUriCjs = require('current-package');
const bundle = await rollup({
input: 'json.js',
plugins: [dataUriCjs()]
});
const { code } = await testBundle(t, bundle);
t.snapshot(code);
const { code } = await testBundle(undefined, bundle);

Check warning on line 63 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v24

Unexpected use of undefined

Check warning on line 63 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v20

Unexpected use of undefined

Check warning on line 63 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v24

Unexpected use of undefined

Check warning on line 63 in packages/data-uri/test/test.mjs

View workflow job for this annotation

GitHub Actions / Node v20

Unexpected use of undefined
expect(code).toMatchSnapshot();
});
Loading
Loading