Skip to content

Commit

Permalink
snapshot on function starts to look wonderful
Browse files Browse the repository at this point in the history
  • Loading branch information
dmail committed Jul 24, 2024
1 parent ac8f3fb commit daa0f24
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@jsenv/package-publish": "1.10.5",
"@jsenv/performance-impact": "4.2.1",
"@jsenv/server": "15.2.14",
"@jsenv/snapshot": "2.4.1",
"@jsenv/snapshot": "2.5.0",
"@jsenv/test": "3.3.17",
"eslint": "8.57.0",
"eslint-plugin-html": "8.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const test = async (scenario, { bareSpecifierAutomapping }) => {
},
}),
import.meta.url,
`./output/${scenario}/`,
`./output/${scenario}.md`,
);
};

await test("0_default", {
await test("0_bare_specifier_warning", {
bareSpecifierAutomapping: undefined,
});
await test("1_bare_specifier_automapping", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ add mapping to "manualImportmap"

```

3. write file "input/0_default.importmap"
3. write file "input/0_bare_specifier_warning.importmap"
```importmap
{
"imports": {},
Expand All @@ -37,7 +37,7 @@ add mapping to "manualImportmap"
4. resolve
```js
{
"0_default.importmap": {
"0_bare_specifier_warning.importmap": {
"imports": {},
"scopes": {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const test = async () => {
},
}),
import.meta.url,
`./output/`,
`./output/auto_mapping_css_to_js.md`,
);
};
await test();
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
1. write file "input/test.importmap"
1. return promise

2. write file "input/test.importmap"
```importmap
{
"imports": {
"./file.css": "./file.css.js"
},
"scopes": {}
}
```

2. resolve
3. resolve
```js
{
"test.importmap": {
"imports": {
"./file.css": "./file.css.js"
},
"scopes": {}
}
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const test = async (scenario, { magicExtensions } = {}) => {
},
}),
import.meta.url,
`./output/${scenario}/`,
`./output/${scenario}.md`,
);
};

await test("0_default", {
await test("0_magic_extensions_warning", {
magicExtensions: undefined,
});
await test("1_magic_extensions_js", {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
1. console.warn
1. return promise

2. console.warn
```console

Import resolution failed for "./file"
--- import trace ---
Expand All @@ -21,21 +24,26 @@ add mapping to "manualImportmap"
}
}

```

2. write file "input/test.importmap"
3. write file "input/test.importmap"
```importmap
{
"imports": {
"leftpad": "./node_modules/leftpad/index.js"
},
"scopes": {}
}
```

3. resolve
4. resolve
```js
{
"test.importmap": {
"imports": {
"leftpad": "./node_modules/leftpad/index.js"
},
"scopes": {}
}
}
}
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
1. console.warn
1. return promise

2. console.warn
```console

Import resolution failed for "./other-file"
--- import trace ---
Expand All @@ -8,8 +11,10 @@ file:///cwd()/input/node_modules/leftpad/file.js:1:7
--- reason ---
file not found on filesystem at cwd()/input/node_modules/leftpad/other-file

```

2. write file "input/test.importmap"
3. write file "input/test.importmap"
```importmap
{
"imports": {
"leftpad": "./node_modules/leftpad/index.js"
Expand All @@ -20,8 +25,10 @@ file not found on filesystem at cwd()/input/node_modules/leftpad/other-file
}
}
}
```

3. resolve
4. resolve
```js
{
"test.importmap": {
"imports": {
Expand All @@ -33,4 +40,5 @@ file not found on filesystem at cwd()/input/node_modules/leftpad/other-file
}
}
}
}
}
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
1. write file "input/test.importmap"
1. return promise

2. write file "input/test.importmap"
```importmap
{
"imports": {
"leftpad": "./node_modules/leftpad/index.js"
Expand All @@ -10,8 +13,10 @@
}
}
}
```

2. resolve
3. resolve
```js
{
"test.importmap": {
"imports": {
Expand All @@ -24,4 +29,5 @@
}
}
}
}
}
```
2 changes: 2 additions & 0 deletions tests/snapshot_write_importmaps_side_effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ export const snapshotWriteImportsMapsSideEffects = async (
fn,
fnFileUrl,
sideEffectDirectoryRelativeUrl,
options,
) => {
await snapshotFunctionSideEffects(
fn,
fnFileUrl,
sideEffectDirectoryRelativeUrl,
options,
);
};

0 comments on commit daa0f24

Please sign in to comment.