chore: more readable snapshots

This commit is contained in:
2024-03-24 18:04:47 +01:00
parent 4cb8daf908
commit 93f99c732f
37 changed files with 1258 additions and 1096 deletions

View File

@@ -1,3 +1,59 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`rewrite-url 1`] = `undefined`;
exports[`rewrite-url 1`] = `
####################
# admin/index.html #
####################
<html><head>
</head>
<body>
<div id="root"></div>
<script src="/admin/app.js" type="module"></script>
</body></html>
##############
# index.html #
##############
<html><head>
</head>
<body>
<div id="root"></div>
<script src="/admin/app.js" type="module"></script>
</body></html>
################
# admin/app.js #
################
const bootstrap = (el,deps = [])=>{
el.innerHtml = \`
<div>load the app</div>
\`;
};
export { bootstrap };
//# sourceMappingURL=app.js.map
####################
# admin/app.js.map #
####################
{"version":3,"file":"app.js","sources":["../../admin/app.js"],"sourcesContent":["export const bootstrap = (el,deps = [])=>{\\n el.innerHtml = \`\\n <div>load the app</div>\\n \`;\\n}\\n"],"names":[],"mappings":"AAAY,MAAC,SAAS,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,GAAG;AACzC,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC;AACpB;AACA,IAAI,CAAC,CAAC;AACN;;;;"}
#################
# RENDERED HTML #
#################
<html><head>
</head>
<body>
<div id="root"></div>
<script src="/admin/app.js" type="module"></script>
</body></html>
#############
# RESPONSES #
#############
200 http://localhost/admin
200 http://localhost/admin/app.js
200 http://localhost/favicon.ico
`;

View File

@@ -1,7 +1,7 @@
import {resolve, join, dirname} from "node:path";
import {test, expect} from "@jest/globals";
import {runBrowserTest} from "../util/index.ts";
import {runBrowserTest, serializer} from "../util/index.ts";
import html from "../../src/index.ts";
@@ -11,6 +11,7 @@ process.chdir(join(__dirname, 'fixtures'));
test('rewrite-url', async () => {
expect.addSnapshotSerializer(serializer);
const out = await runBrowserTest({
input: {
['index']: 'index.html',
@@ -34,7 +35,7 @@ test('rewrite-url', async () => {
format: 'es', // iifi and cjs should be added to tests
sourcemap: true,// Test if #sourcemapUrl is not accidentally included in the html-output
});
expect(out.code).toMatchSnapshot(); // Snapshot the result code
expect(out).toMatchSnapshot(); // Snapshot the result code
// const bundle = await rollup({
// input: {