Skip to content

Your configFile is invalid [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" #27450

Closed
@wakaztahir

Description

@wakaztahir

Current behavior

package.json

{
    "name": "@something/editor",
    "version": "0.0.1",
    "description": "a library",
    "module": "index.js",
    "types": "index.d.ts",
    "scripts": {
        "browser-tests": "cypress run --browser chrome",
    },
    "devDependencies": {
        "@babel/core": "^7.22.9",
        "@rollup/plugin-babel": "^6.0.3",
        "@rollup/plugin-commonjs": "^25.0.3",
        "@rollup/plugin-node-resolve": "^15.1.0",
        "@rollup/plugin-terser": "^0.4.3",
        "@rollup/plugin-typescript": "^11.1.2",
        "create-ts-index": "^1.14.0",
        "cypress": "^12.17.2",
        "rollup": "^3.26.3",
        "rollup-plugin-multi-input": "^1.4.1",
        "rollup-plugin-node-externals": "^6.1.1",
        "rollup-plugin-summary": "^2.0.0",
        "ts-node": "^10.9.1",
        "tsc-watch": "^6.0.4",
        "typescript": "^5.1.6",
        "webpack": "^5.88.2"
    },
    "dependencies": {
        "@babel/plugin-transform-runtime": "^7.22.9"
    }
}

cypress.config.ts

import {defineConfig} from "cypress";

export default defineConfig({
    e2e: {
        setupNodeEvents(on, config) {
            // implement node event listeners here
        },
        specPattern: "tests/*.{js,jsx,ts,tsx}",
        supportFile: false
    },
    video: false,
    screenshotOnRunFailure : false
});

error

Your configFile is invalid: D:\Programming\Web\RtEdit\packages\lib\cypress.config.ts

It threw an error when required, check the stack trace below:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for D:\Programming\Web\RtEdit\packages\lib\cypress.config.ts
    at new NodeError (node:internal/errors:393:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:121:38)
    at defaultLoad (node:internal/modules/esm/load:81:20)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:605:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:63:26)
    at #createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15)
    at async loadFile (C:\Users\wakaz\AppData\Local\Cypress\Cache\12.17.3\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_require_async_child.js:106:14)    
    at async EventEmitter.<anonymous> (C:\Users\wakaz\AppData\Local\Cypress\Cache\12.17.3\Cypress\resources\app\node_modules\@packages\server\lib\plugins\child\run_require_async_child.js:116:32)

tsconfig.json

{
  "extends": [
    "./tsconfig.build.json",
    "./tsconfig.tests.json"
  ]
}

tsconfig.build.json

{
    "extends": "../../tsconfig.base.json",
    "compilerOptions": {
        "noEmitOnError": true,
        "moduleResolution": "NodeNext",
    },
    "include": [
        "src"
    ],
    "exclude": [
        "dist"
    ]
}

tsconfig.tests.json

{
    "extends": "../../tsconfig.base.json",
    "compilerOptions": {
        "noEmitOnError": true,
        "types": ["cypress"],
        "moduleResolution": "NodeNext",
    },
    "include": [
        "src",
        "tests",
        "cypress.config.ts"
    ],
    "exclude": [
        "dist"
    ]
}

Desired behavior

Cypress should run all the tests since typescript is installed, Its a monorepo, The issue occurs even after yarn install after deleting the yarn lock file, I've tried everything in other issues but issue doesn't seem to resolve, however changing the type field in package.json does change the output of the error

Test code to reproduce

Currenlty the project is huge, Requires a bit of work to reproduce

Cypress Version

v12.17.2

Node version

v18.12.1

Operating System

Windows 11

Debug Logs

No response

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions