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

0

17
Views
How to use absolute path in enzyme

I use Enzyme and React 17.0.2 together

jsconfig.json

{
    "compilerOptions": {
        "baseUrl": "src"
    },
    "include": [
        "src"
    ]
}

enzymeConfig.js

import { configure } from "enzyme";
import Adapter from "@wojtekmaj/enzyme-adapter-react-17";

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

Login.test.js

import React from "react";
import { mount } from "enzyme";
import '../../enzymeConfig';
import Login from "components/Layout/Login/FormSide/Login";

describe('Test login form', () => {
    let wrapper;

    it("Username created correctly.", function () {
        wrapper = mount(<Login />);
        wrapper.find('input[type="text"]').simulate("change", {
            target: { value: 'something' }
        });
        expect(wrapper.state("username")).toEqual("world");
    });
});

I use absolute path in react and I haven't issue But in Enzyme I get the following error:

Cannot find module 'components/Layout/Login/FormSide/Login' from 'src/__tests__/Login.test.js'

How can i use absolute path in Enzyme?

7 months ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.