-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Labels
TriagedIssue has been routed to backlog. This is not a commitment to have it prioritized by the team.Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.prevent-stalemark an issue so it is ignored by stale[bot]mark an issue so it is ignored by stale[bot]topic: typescript
Description
Current behavior
If I use the code from the snippet here for TypeScript it breaks the project:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/george/Documents/core-cypress/cypress.config.ts
at new NodeError (node:internal/errors:372:5)
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:76:11)
at defaultGetFormat (node:internal/modules/esm/get_format:118:38)
at defaultLoad (node:internal/modules/esm/load:21:20)
at ESMLoader.load (node:internal/modules/esm/loader:407:26)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:326:22)
at new ModuleJob (node:internal/modules/esm/module_job:66:26)
at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:345:17)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:304:34)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
at async loadFile (/Users/george/Library/Caches/Cypress/10.3.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:106:14)
at async EventEmitter.<anonymous> (/Users/george/Library/Caches/Cypress/10.3.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:116:32)
Even just this line breaks the project:
const del = require('del')
Desired behavior
I can run my tests and the videos are deleted if test passed.
Test code to reproduce
/* eslint @typescript-eslint/no-var-requires: "off" */
import { defineConfig } from "cypress";
import { checkGmail, CheckGmailParam } from "../core-cypress/cypress/plugins/checkGmail";
import * as path from "path";
const del = require('del')
export default defineConfig({
e2e: {
async setupNodeEvents(on, config) {
const version = config.env.version || 'development'
const configFile = await import(path.join(
config.projectRoot,
'cypress/config',
`${version}.json`
));
config.projectId = "5jgpns"
config.baseUrl = configFile.baseUrl
config.env = configFile.env
config.defaultCommandTimeout = 10000
config.chromeWebSecurity = false
on("task", {
async checkGmail(args: CheckGmailParam) {
return await checkGmail(args);
},
});
on('after:spec', (spec, results) => {
if (results && results.stats.failures === 0 && results.video) {
// `del()` returns a promise, so it's important to return it to ensure
// deleting the video is finished before moving on
return del(results.video)
}
})
return config
},
reporter: 'mochawesome'
},
});
Cypress Version
10.1.0
Other
Current snippet also isn't 100% TypeScript/Eslint friendly because uses require
instead of import
and has unused parameter. Something like this should work right?
import { deleteAsync } from 'del'
on('after:spec', async (_spec, results) => {
if (results && results.stats.failures === 0 && results.video) {
// `del()` returns a promise, so it's important to return it to ensure
// deleting the video is finished before moving on
await deleteAsync(results.video)
}
})
nikepol, SmileJayden, S1r-Lanzelot, klofi and cragrock8990IcyW
Metadata
Metadata
Assignees
Labels
TriagedIssue has been routed to backlog. This is not a commitment to have it prioritized by the team.Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.prevent-stalemark an issue so it is ignored by stale[bot]mark an issue so it is ignored by stale[bot]topic: typescript