chore: switch to jest for testing

This commit is contained in:
2024-02-21 00:04:36 +01:00
parent 3b540d0c48
commit e46f668ac8
47 changed files with 50329 additions and 839 deletions

View File

@@ -1,65 +1,10 @@
import {Plugin, InputPluginOption, RollupOptions, OutputOptions, RollupOutput} from "rollup";
import {TestOptions as BrowserTestOptions, TestOutput as PuppeteerTestOutput} from "./puppeteer-run-test.js";
import { rollup } from "rollup";
import serveTest, {LogCallback} from "./serve-test.js";
import serveTest, {LogCallback} from "./serve-test.ts";
import type {ExecutionContext} from "ava";
import {getCode, TestOutput} from "./code-output.ts";
// /**
// * The AVA context used to test (ie t.snapshot(..) )
// */
// t: ExecutionContext
//
//
// filterOutput:{
// html: true,
// console: ['log','error','warn'],// TODO: or warning? need to check what possible values are
// errors: true, // again don't know possible values
// responses: true, // interesting to see what other values were requested
// requestsFailed: true, // will probably also be replicated into console errors, but helpful to have if imports werent found
// }
// try{
// // Track requests, errors and console
// page.on('console', message => {
// let [type, text] = [message.type(), message.text()];
// if(replaceHost){
// text = text.replaceAll(hostUrl, replaceHostWith!);
// }
// if((<any>filterOutput.console)?.includes?.(<any>type) ?? (filterOutput.console === true)){// TODO: add callback option
// output.console?.push(`[${type}] ${text}`);
// }
// }).on('pageerror', ({ message }) => {
// let text = message;
// if(replaceHost){
// text = text.replaceAll(hostUrl, replaceHostWith!);
// }
// if(filterOutput.errors === true) {// TODO add callback option
// output.errors?.push(text)
// }
// }).on('response', response => {
// let [status, url] = [response.status(), response.url()]
// if(replaceHost){
// url = url.replaceAll(hostUrl, replaceHostWith!);
// }
// if(filterOutput.responses === true) {// TODO add callback option
// output.responses?.push(`${status} ${url}`)
// }
// }).on('requestfailed', request => {
// let [failure, url] = [request.failure()?.errorText, request.url()];
// if(replaceHost){
// failure = failure?.replaceAll(hostUrl, replaceHostWith!);
// url = url.replaceAll(hostUrl, replaceHostWith!);
// }
// if(filterOutput.requestsFailed === true) {// TODO add callback option
// output.requestsFailed?.push(`${failure} ${url}`)
// }
// });
// testOptions.t?.snapshot?.(testOutput);
export interface OutputFilterOptions {
html?: boolean
console?: ('log'|'error'|'warn')[] | true
@@ -123,6 +68,7 @@ export async function runBrowserTest(
if(output){
testOutput.code = await getCode(bundle, output);
}
await bundle.close();
return testOutput