mercredi 23 janvier 2019

Jest can't find component imported in my test

My branch: https://github.com/Futuratum/moonholdings.io/tree/JestTests

My super simple test (no errors in VSCode):

import React from 'react';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';

import Astronaut from './Astronaut';

describe('<Astronaut /> component', () => {
  console.log('Astronaut', Astronaut);
  describe('when rendering', () => {
    const wrapper = shallow(<Astronaut {...props} />);

    it('should render a component matching the snapshot', () => {
      const tree = toJson(wrapper);
      expect(tree).toMatchSnapshot();
      expect(wrapper).toHaveLength(1);
    });
  });
});

Folder structure:

enter image description here

The error:

enter image description here

Any thoughts of why it's complaining?

My Jest config:

"jest": {
    "setupTestFrameworkScriptFile": "<rootDir>/jest.setup.js",
    "testPathIgnorePatterns": [
      "<rootDir>/.next/",
      "<rootDir>/node_modules/"
    ],
    "transform": {
      "\\.(gql|graphql)$": "jest-transform-graphql",
      ".*": "babel-jest",
      "^.+\\.js?$": "babel-jest"
    }
  }

Aucun commentaire:

Enregistrer un commentaire