inflearn logo
강의

Course

Instructor

Learn React Testing by Following [Updated November 2023]

axios 1.1.2 버전 issue ( SyntaxError: Cannot use import statement outside a module)

2222

kiminpyo

11 asked

4

혹시나 에러가 나신다면,

package.json폴더에

 "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!axios)/\"",
        "eject": "react-scripts eject"
    },

로 변경 후 test를 종료 후 재 실행시키면 됩니다.

방법은 test에서 직접 스크립트 수정하거나 jest.config.js파일을 만들어 moduleNameMapper을 사용하시면 됩니다!

참고

https://stackoverflow.com/questions/73958968/cannot-use-import-statement-outside-a-module-with-axios

https://jestjs.io/docs/configuration#modulenamemapper-objectstring-string--arraystring

jest 웹앱 react React-Context

Answer 5

0

Alex Madnix

감사합니다.

0

hxxtae

공유해 주셔서 감사합니다.

0

koreantie3931

너무 감사합니다!

0

Hyunjo Kim

정말... 감사합니다...

0

John Ahn

좋은 정보 공유 감사합니다.

제공해주신 코드를 vscode에서 켜도 eslint가 안됩니다.

0

278

2

ERROR

0

209

1

테스트 시간을 단축할 수 있는 방법에 대하여 문의드립니다.

0

360

1

useState 배열값 변경의 경우 테스트 멈춤

0

411

1

test was not wrapped in act관련 질문

0

290

2

안녕하세요! 로딩 상태 테스트에 관련된 질문입니다.

0

394

1

강의 관련 내용 github 업로드 질문

0

307

1

이미지가 안보인다 하셔서 다시 질문드립니다.

0

414

2

Test Fail이 발생합니다 ㅠㅠ

0

356

1

스타일 컴포넌트 테스트 방법

0

438

1

msw 에러

0

630

1

toHaveTextContent 에러

0

442

1

msw안돼는사람

0

579

1

This could be because the text is broken up by multiple elements. 에러

0

1716

2

Type.test.js파일에 궁금한점이 생겼습니다

0

351

1

28강 수강 중 JSX 작성 방법에 대해 궁금해져서 질문 남깁니다!

0

398

1

toHaveTextContent 에서 에러가 자꾸 나는데 아무리 찾아도 잘 모르겠습니다.

0

610

2

aria-*

0

438

1

This XML file does not appear to have any style information associated with it. The document tree is shown below. 에러

1

14082

1

컴포넌트 props내려줄때 코드는 어떻게 해야하나요

0

246

0

es6 jest 미지원 오류 문의

0

855

1

test 여러 개 실행 - fail 발생

0

290

1

useMemo

0

280

1

2가지 질문사항입니다!

0

308

2