chore: switch to jest for testing
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {join, dirname} from "node:path";
|
||||
import {test, expect} from "@jest/globals";
|
||||
|
||||
import test from "ava";
|
||||
import * as rollup from "rollup";
|
||||
import {debugPrintOutput, getCode} from "../util/index.ts";
|
||||
import {resolve} from "node:path";
|
||||
@@ -12,6 +12,10 @@ const output = {
|
||||
dir: 'output', // Output all files
|
||||
format: 'es', // iifi and cjs should be added to tests
|
||||
sourcemap: true,// Test if #sourcemapUrl is not accidentally included in the html-output
|
||||
// Prevent hashes from being added (and screw up the snapshots)
|
||||
chunkFileNames: '[name].js',
|
||||
entryFileNames: '[name].[extname]',
|
||||
assetFileNames: '[name].[extname]',
|
||||
};
|
||||
|
||||
import {fileURLToPath} from "node:url";
|
||||
@@ -20,7 +24,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
process.chdir(join(__dirname, 'fixtures'));
|
||||
|
||||
|
||||
test.serial('watch', async (t) => {
|
||||
test('watch', async () => {
|
||||
const origContent = `
|
||||
export const a = 1; // DO NOT CHANGE ME HERE, but in ../test.js
|
||||
`;
|
||||
@@ -56,25 +60,26 @@ test.serial('watch', async (t) => {
|
||||
await writeFile(path, origContent, {encoding: 'utf-8'});
|
||||
|
||||
// Assert the output is what we exapect;
|
||||
t.snapshot(code);
|
||||
expect(code).toMatchSnapshot();
|
||||
|
||||
watcher
|
||||
},
|
||||
];
|
||||
const log = console.log;
|
||||
|
||||
await new Promise((resolve, reject)=>{
|
||||
watcher.on('event', async (event) => {
|
||||
const {result} = event;
|
||||
switch (event.code) {
|
||||
case "START":
|
||||
t.log(`WATCH STARTED`);
|
||||
log(`WATCH STARTED`);
|
||||
break;
|
||||
case "BUNDLE_START":
|
||||
t.log(`REBUILDING...`);
|
||||
log(`REBUILDING...`);
|
||||
|
||||
break;
|
||||
case "BUNDLE_END":
|
||||
t.log(`Rebuilt...`);
|
||||
log(`Rebuilt...`);
|
||||
const cb = steps.shift();
|
||||
|
||||
const generated = await result.generate(output);
|
||||
@@ -94,4 +99,6 @@ test.serial('watch', async (t) => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await watcher.close();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user