Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

75
Views
How to implement React Enzyme testing in Bit Harmony

I'm trying to move an existing react library to Bit Harmony. The original library used Enzyme for testing. When I try to modify the demo my-react environment to use enzyme instead I hit an issue with specifying the location of the setupTests.js file.

I have modified the jest.config.js file located at demo/envs/my-react/jest to match the following:

module.exports = {
    setupFilesAfterEnv: [
    // I have tried multiple variations of the below path
      '<rootDir>/demo/envs/my-react/jest/setupTests.js',
    ],
  };

I have then created a setupTests.js file next to the jest.config.js file.

import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

With this setup I still get the following error when running the test which seems to indicate the setupTests file is not being called. Enzyme Internal Error: Enzyme expects an adapter to be configured, but found none.

Note that copying the setupTests.js code directly into a test file allows the test to pass.

7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs