英文:
Cypress - error occurs when I installed 'del' module, cant open cypress
问题
我安装了del模块:https://docs.cypress.io/api/plugins/after-spec-api#Delete-the-recorded-video-if-the-spec-passed
然后我配置了Cypress配置,但这行代码:
const del = require('del')
导致Cypress无法正常工作(甚至无法选择任何浏览器):
当我注释掉这行代码(const del = require('del')
)时,Cypress正常工作。
我该如何修复它?
- Cypress版本:12.5
- del版本:7.0.0
英文:
I installed del module:
https://docs.cypress.io/api/plugins/after-spec-api#Delete-the-recorded-video-if-the-spec-passed
then I configured cypress config but this line:
const del = require('del')
makes that cypress is not working (I cant even select any browser):
When I commented out this line (const del = require('del')), cypress worked normally.
How can I fix it?
- Cypress version: 12.5
- del version: 7.0.0
答案1
得分: 1
The latest version of del
v7.0.0 isn't compatible with the example code Cypress gives.
You could downgrade to v6.1.1 and the sample code will run.
npm install del@6.1.1
I would remove ver 7.0.0 first to be sure you get the older version installed.
You can use ver 7.0.0 and alter the code to use dynamic import.
The newest version also changes the function names to deleteAsync
and deleteSync
, so the usage is slightly different.
Here's the changes to the Cypress sample code:
const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('after:spec', (spec, results) => {
if (results && results.stats.failures === 0 && results.video) {
return import('del').then(del => {
return del.deleteSync(results.video)
})
}
})
},
},
})
英文:
The latest version of del
v7.0.0 isn't compatible with the example code Cypress gives.
You could downgrade to v6.1.1 and the sample code will run.
npm install del@6.1.1
I would remove ver 7.0.0 first to be sure you get the older version installed.
You can use ver 7.0.0 and alter the code to use dynamic import.
The newest version also changes the function names to deleteAsync
and deleteSync
, so the usage is slightly different.
Here's the changes to the Cypress sample code:
const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('after:spec', (spec, results) => {
if (results && results.stats.failures === 0 && results.video) {
return import('del').then(del => {
return del.deleteSync(results.video)
})
}
})
},
},
})
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论