Search code examples
reactjstestingava

Cannot find module at AVA test


I am trying to setup the AVA at my react project.

So I added this code into my package.json:

 "ava": {
    "babel": "inherit",
    "register": [
      "babel-register",
      "./test/helpers/browser-env.js",
      "ignore-styles"
    ]
  }

  "scripts": {
    ...
    "test": "ava \"app/**/*.test.js\" --verbose"
   }

And made the Header.test.js:

import test from 'ava';

import React from 'react';
import { renderJSX } from 'jsx-test-helpers';

import Header from './Header';

test('it renders', (t) => {
  const wrapper = renderJSX(<Header attendant={null} />);
  t.true(wrapper);
});

When I run the test I got this error:

Error: Cannot find module './Header'

The picture from my folder structure:

My folder structure

Any help?


Solution

  • You might need to import ./Header.jsx.