Skip to content

When using with Jest, EISDIR: illegal operation on a directory #3

Open
@kerbe

Description

@kerbe

I have tried starting to use this package, but running problems on very beginning.

I have test file like this:

// __tests__/index.test.jsx

import { render, screen } from '@testing-library/react'
import { withMockAuth } from '@tomfreudenberg/next-auth-mock/jest'
import Home from '../pages/index'
import '@testing-library/jest-dom'

describe('Home', () => {
  it('renders a heading', () => {
    render(<Home />)

    const heading = screen.getByRole('heading', {
      name: /welcome to next\.js!/i,
    })

    expect(heading).toBeInTheDocument()
  })
})

And when I run jest to test that, I get following error:

 FAIL  __tests__/index.test.jsx
  ● Test suite failed to run

    EISDIR: illegal operation on a directory, read

       6 | import '@testing-library/jest-dom'
       7 |
    >  8 | describe('Home', () => {
         |               ^
       9 |   it('renders a heading', () => {
      10 |     render(<Home />)
      11 |

      at Runtime.readFile (node_modules/jest-runtime/build/index.js:2574:21)
      at Object.<anonymous> (__tests__/index.test.jsx:8:15)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.421 s
Ran all test suites related to changed files.

This problem appears whenever I have import for withMockAuth present, ie this line:

import { withMockAuth } from '@tomfreudenberg/next-auth-mock/jest'

If I remove that line, all works as expected (I get error that useSession needs to be wrapped within SessionProvder). Adding that withMockAuth inside render() call doesn't change output in any way from EISDIR error.

I've wiped my node_modules and installed things again, but hasn't changed outcome. Any ideas for further fixing this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions