path-serializer
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

path-serializer

npm latest version

  1. stabilize pnpm dependencies path in snapshot
  2. transform win32 path to posix path
  3. escapeEOL \r\n -> \n and more...
// __snapshots__/index.test.ts.snap
// 😭 bad
{
  "loader" : "D:\\user\\rspack\\node_modules\\.pnpm\\css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_@swc+core@1.4.0_@swc+helpers@0._jlcdgjlw2ezzhg43ml3d627wdu\\node_modules\\css-loader\\utils.ts"
}
//😎👍🏻 good
{
  "loader" : "<ROOT>/node_modules/<PNPM_INNER>/css-loader/utils.ts"
}

Usage

// vitest.setup.ts
import { createSnapshotSerializer } from 'path-serializer';

expect.addSnapshotSerializer(
  createSnapshotSerializer({
    root: path.join(__dirname, '..'),
  }),
);

More features can be found in ./src/types.ts

Showcases

Rslib

Rsbuild

Rspack

Package Sidebar

Install

npm i path-serializer

Weekly Downloads

11,758

Version

0.4.0

License

MIT

Unpacked Size

80.3 kB

Total Files

7

Last publish

Collaborators

  • sooniter