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

沒有動到cypress檔案的情況下,cypress無法測試 #48

Open
jasperchan5 opened this issue Dec 7, 2021 · 4 comments
Open

沒有動到cypress檔案的情況下,cypress無法測試 #48

jasperchan5 opened this issue Dec 7, 2021 · 4 comments

Comments

@jasperchan5
Copy link

我在重啟使用cypress測試的終端機之後,就無法使用npm test測試了,一直顯示這個:
The plugins file is missing or invalid.
Your pluginsFile is set to C:\Users\jaspe\wp1101\hack2\cypress\plugins\index.js, but either the file is missing, it contains a syntax error, or threw an error when required. The pluginsFile must be a .js, .ts, or .coffee file.

Or you might have renamed the extension of your pluginsFile. If that's the case, restart the test runner.

Please fix this, or set pluginsFile to false if a plugins file is not necessary for your project.

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\jaspe\wp1101\hack2\cypress\plugins\index.js from C:\Users\jaspe\AppData\Local\Cypress\Cache\9.1.1\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js not supported.
index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in C:\Users\jaspe\wp1101\hack2\package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

at runPlugins (C:\Users\jaspe\AppData\Local\Cypress\Cache\9.1.1\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:175:15)
at Object.<anonymous> (C:\Users\jaspe\AppData\Local\Cypress\Cache\9.1.1\Cypress\resources\app\packages\server\lib\plugins\child\index.js:8:25)

然而我完全沒有動到這些檔案。

@raywu0123
Copy link

你有 C:\Users\jaspe\wp1101\hack2\cypress\plugins\index.js 這個檔案嗎

@jasperchan5
Copy link
Author

jasperchan5 commented Dec 7, 2021

有,我根本沒有動過它
他一直都在

@ntuee-webprogramming
Copy link
Owner

雖然不知道是什麼問題,但建議先參考 cypress/integration/public.spec.js 然後手動測試就好。屆時我們會用自己的環境來測 cypress, 應該不會有問題。

@raywu0123
Copy link

我查到一個類似的問題 cypress-io/cypress#8994

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

No branches or pull requests

3 participants