Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Establishment of FE automated testing environment #403

Open
tsuchiyama-araya opened this issue Aug 6, 2024 · 5 comments · Fixed by #418 or #426
Open

Establishment of FE automated testing environment #403

tsuchiyama-araya opened this issue Aug 6, 2024 · 5 comments · Fixed by #418 or #426
Assignees
Labels

Comments

@tsuchiyama-araya
Copy link
Collaborator

tsuchiyama-araya commented Aug 6, 2024

FE自動テストの環境構築

【完了条件】

  • 今までのフロントエンドテストが問題なく動くこと
  • 新しいテストにWarningやエラーの線が出ないこと
@tsuchiyama-araya tsuchiyama-araya self-assigned this Aug 6, 2024
@tsuchiyama-araya tsuchiyama-araya changed the title FE自動テストの環境構築 Establishment of FE automated testing environment Aug 6, 2024
@tsuchiyama-araya
Copy link
Collaborator Author

テストを動かすとnode_modulesのエラーが表示されます。

Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

@tsuchiyama-araya
Copy link
Collaborator Author

node_modulesの対策をしてみましたがまた新しいエラーが表示されました。

Test suite failed to run

    Cannot find module '/Users/tsuchiyama/Developer/barebone-studio/frontend/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/interopRequireDefault.js' from 'src/components/Workspace/FlowChart/TreeView.tsx'

    Require stack:
      src/components/Workspace/FlowChart/TreeView.tsx
      src/components/Workspace/FlowChart/__tests__/TreeView.test.tsx

      1 | import { memo, useCallback, useEffect } from "react"
      2 | import { useDrag } from "react-dnd"
    > 3 | import { useSelector, useDispatch } from "react-redux"
        |                              ^
      4 |
      5 | import AddIcon from "@mui/icons-material/Add"
      6 | import ChevronRightIcon from "@mui/icons-material/ChevronRight"

【行なった対策】
https://zenn.dev/t_yng/scraps/d701cdae1071fd
https://qiita.com/miyuc/items/a5cae6252231e224f57f
https://qiita.com/Sicut_study/items/ba23e8b8a22a3b5b0b3e
https://zenn.dev/s_takashi/articles/72d864681aab1d
https://stackoverflow.com/questions/71058618/to-have-some-of-your-node-modules-files-transformed-you-can-specify-a-custom

@itutu-tienday
Copy link
Collaborator

itutu-tienday commented Aug 21, 2024

調査状況メモ

@itutu-tienday
Copy link
Collaborator

itutu-tienday commented Aug 22, 2024

調査状況メモ # 2

  • 以下の指定を試したが、機能しているようだが、動作が不安定であるようなため、他の対処方法を追加調査
    react-app-rewired test --transformIgnorePatterns "node_modules/(?!react-dnd)/"

    • 課題) transformIgnorePatterns 自体は機能しているようだが、正規表現パターンが機能していない?
  • 対策

上記の対策は機能している模様。
ただし、対策後も transformIgnorePatterns 指定版と同様のエラーが出ているため、
このエラーが引き続き環境構築起因のものか、単にテストコードの不備に起因するものか、確認を要継続。

@itutu-tienday itutu-tienday linked a pull request Aug 22, 2024 that will close this issue
@tsuchiyama-araya
Copy link
Collaborator Author

tsuchiyama-araya commented Aug 29, 2024

進捗メモ

・Jestの環境に関する問題で時間が大幅にかかってしまいました。そのため、実際に1週間ほどかかりました。
・現在、Jestの問題は解決しましたが、テストがまだすべて通過していないため、環境が完全に整っているかどうかはまだ確信が持てません。

8月30日
・テストの書き方に問題があったことが確認できたため、環境構築は一旦解決しました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants