Skip to content

Commit

Permalink
fix: unbreak inline snapshots
Browse files Browse the repository at this point in the history
Sadly, Prettier v3 breaks inline snapshots:

   FAIL  packages/legacy/src/parser/__tests__/parse-test.ts
    ● Test suite failed to run

      Jest: Inline Snapshots are not supported when using Prettier 3.0.0 or above.
      See https://jestjs.io/docs/configuration/#prettierpath-string for alternatives.

        at saveInlineSnapshots (node_modules/jest-snapshot/build/InlineSnapshots.js:101:15)

So, as noted in:

- jestjs/jest#14367

set `prettierPath` in the Jest config, install v2 just for use by Jest,
update the snapshots, which now have an, um, prettier format, like this:

    -       "selections": Array [
    -         Object {
    +       "selections": [
    +         {

and then re-run Prettier manually with `yarn format` to make sure that
everything remains stable.
  • Loading branch information
wincent committed Aug 2, 2023
1 parent 96969e7 commit 06c0f07
Show file tree
Hide file tree
Showing 9 changed files with 3,357 additions and 3,350 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Expand Up @@ -12,6 +12,7 @@ module.exports = {
'@masochist/(.+)$': '<rootDir>packages/$1/src',
},
preset: 'ts-jest',
prettierPath: require.resolve('prettier-v2-for-jest-inline-snapshots'),
testMatch: ['**/__tests__/**/*-test.[jt]s?(x)'],
testPathIgnorePatterns: [
...defaults.testPathIgnorePatterns,
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -14,6 +14,7 @@
"@types/node": "*",
"jest": "*",
"prettier": "*",
"prettier-v2-for-jest-inline-snapshots": "npm:prettier@^2",
"ts-jest": "*",
"typescript": "*"
},
Expand Down

0 comments on commit 06c0f07

Please sign in to comment.