Skip to content

Error when running with Jest & toMatchInlineSnapshot: Cannot read properties of undefined (reading 'filepath') #40

@penspinner

Description

@penspinner

I'm running into this issue while running Jest v27.4.7:

    TypeError: Cannot read properties of undefined (reading 'filepath')

      at Object.parse (node_modules/prettier-plugin-tailwindcss/dist/index.js:145:1735)
      at Object.parse$d [as parse] (node_modules/prettier/index.js:12975:19)
      at coreFormat (node_modules/prettier/index.js:14525:16)
      at formatWithCursor$1 (node_modules/prettier/index.js:14765:14)
      at node_modules/prettier/index.js:60959:12
      at Object.format (node_modules/prettier/index.js:60979:12)

This seems to happen when Jest tries to write out an inline snapshot:

test('a test', () => {
  // In this case, the inline snapshot has not been written yet. When running tests with
  // Jest, it fails with the error above and the inline snapshot is never written.
  expect('abc').toMatchInlineSnapshot()
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions