chore: reowrked tests to use a runBrowserTest to allow previewing the results in a browser
This commit is contained in:
@@ -1,24 +1,17 @@
|
||||
import {resolve, join, dirname} from "node:path";
|
||||
import * as path from "node:path";
|
||||
import test from "ava";
|
||||
import { rollup } from "rollup";
|
||||
import {debugPrintOutput, getCode} from "../util/index.ts";
|
||||
import {runBrowserTest} from "../util/index.ts";
|
||||
|
||||
import html from "../../src/index.ts";
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
import {fileURLToPath} from "node:url";
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
process.chdir(join(__dirname, 'fixtures'));
|
||||
|
||||
|
||||
test.serial('rewrite-url', async (t) => {
|
||||
const bundle = await rollup({
|
||||
|
||||
const out = await runBrowserTest({
|
||||
input: {
|
||||
['index']: 'index.html',
|
||||
['admin/index']: resolve(__dirname,'fixtures','admin/index.html'),
|
||||
@@ -30,11 +23,38 @@ test.serial('rewrite-url', async (t) => {
|
||||
return `/${rootPath}`;
|
||||
}
|
||||
}),
|
||||
]
|
||||
],
|
||||
},{
|
||||
log: t.log,
|
||||
filterOutput:{
|
||||
// TODO: Currently only need the "await getCode(bundle, output);" as output
|
||||
},
|
||||
path: '/admin'
|
||||
}, {
|
||||
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
|
||||
});
|
||||
const code = await getCode(bundle, output);
|
||||
debugPrintOutput('rewrite-url',code);
|
||||
t.snapshot(code);
|
||||
|
||||
t.snapshot(out.code); // Snapshot the result code
|
||||
|
||||
// const bundle = await rollup({
|
||||
// input: {
|
||||
// ['index']: 'index.html',
|
||||
// ['admin/index']: resolve(__dirname,'fixtures','admin/index.html'),
|
||||
// ['admin/app']: resolve(__dirname,'fixtures','admin/app.js'),
|
||||
// },
|
||||
// plugins: [
|
||||
// html({
|
||||
// rewriteUrl(relative, {rootPath, from}){
|
||||
// return `/${rootPath}`;
|
||||
// }
|
||||
// }),
|
||||
// ]
|
||||
// });
|
||||
// const code = await getCode(bundle, output);
|
||||
// debugPrintOutput('rewrite-url',code);
|
||||
// t.snapshot(code);
|
||||
});
|
||||
|
||||
// TODO various parameters
|
||||
|
||||
Reference in New Issue
Block a user