chore: more readable snapshots
This commit is contained in:
@@ -1,49 +1,28 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`handlebars 1`] = `
|
||||
[
|
||||
{
|
||||
"code": "const b = ()=>'batman';
|
||||
console.log(b());
|
||||
|
||||
export { b };
|
||||
//# sourceMappingURL=batman.js.map
|
||||
",
|
||||
"fileName": "batman.js",
|
||||
"map": SourceMap {
|
||||
"file": "batman.js",
|
||||
"mappings": "AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;",
|
||||
"names": [],
|
||||
"sources": [
|
||||
"../batman.js",
|
||||
],
|
||||
"sourcesContent": [
|
||||
"export const b = ()=>'batman';
|
||||
console.log(b());
|
||||
",
|
||||
],
|
||||
"version": 3,
|
||||
},
|
||||
"source": undefined,
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "batman.js.map",
|
||||
"map": undefined,
|
||||
"source": "{"version":3,"file":"batman.js","sources":["../batman.js"],"sourcesContent":["export const b = ()=>'batman';\\nconsole.log(b());\\n"],"names":[],"mappings":"AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;"}",
|
||||
},
|
||||
{
|
||||
"code": undefined,
|
||||
"fileName": "index.html",
|
||||
"map": undefined,
|
||||
"source": "<html><head>
|
||||
<meta data-test="a">
|
||||
</head>
|
||||
<body>
|
||||
<script src="batman.js" type="module"></script>
|
||||
|
||||
|
||||
</body></html>",
|
||||
},
|
||||
]
|
||||
##############
|
||||
# index.html #
|
||||
##############
|
||||
<html><head>
|
||||
<meta data-test="a">
|
||||
</head>
|
||||
<body>
|
||||
<script src="batman.js" type="module"></script>
|
||||
|
||||
|
||||
</body></html>
|
||||
#############
|
||||
# batman.js #
|
||||
#############
|
||||
const b = ()=>'batman';
|
||||
console.log(b());
|
||||
|
||||
export { b };
|
||||
//# sourceMappingURL=batman.js.map
|
||||
|
||||
#################
|
||||
# batman.js.map #
|
||||
#################
|
||||
{"version":3,"file":"batman.js","sources":["../batman.js"],"sourcesContent":["export const b = ()=>'batman';\\nconsole.log(b());\\n"],"names":[],"mappings":"AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;"}
|
||||
`;
|
||||
|
||||
@@ -3,7 +3,7 @@ import {test, expect} from "@jest/globals";
|
||||
|
||||
import { rollup } from "rollup";
|
||||
|
||||
import {debugPrintOutput, getCode} from "../util/index.ts";
|
||||
import {debugPrintOutput, getCode, serializer} from "../util/index.ts";
|
||||
|
||||
import html from "../../src/index.ts";
|
||||
import handlebars from "handlebars";
|
||||
@@ -13,10 +13,14 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
process.chdir(join(__dirname, 'fixtures'));
|
||||
|
||||
test('handlebars', async () => {
|
||||
expect.addSnapshotSerializer(serializer);
|
||||
const bundle = await rollup({
|
||||
input: 'index.hbs',
|
||||
plugins: [
|
||||
html({
|
||||
include: [
|
||||
'**/*.(html|hbs)',// html or handlebars
|
||||
],
|
||||
transform(src){
|
||||
return handlebars.compile(src)({a:'a'})
|
||||
}
|
||||
@@ -25,7 +29,7 @@ test('handlebars', async () => {
|
||||
});
|
||||
const code = await getCode(bundle);
|
||||
debugPrintOutput('handlebars',code);
|
||||
expect(code).toMatchSnapshot();
|
||||
expect({code}).toMatchSnapshot();
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user