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 10.1.0 and 10.2.0 ERR_UNKNOWN_FILE_EXTENSION typescript #688

Closed
Alqio opened this issue Jun 28, 2022 · 18 comments
Closed

Cypress 10.1.0 and 10.2.0 ERR_UNKNOWN_FILE_EXTENSION typescript #688

Alqio opened this issue Jun 28, 2022 · 18 comments

Comments

@Alqio
Copy link

Alqio commented Jun 28, 2022

I'm using cypress/included:10.2.0 image to run headless tests on a GitHub action workflow. The following is my cypress docker configuration:

  cypress_headless:
    image: cypress/included:10.2.0
    entrypoint: cypress run --env BASE_URL=front_test:3000 --project .
    working_dir: /app
    networks:
      - cinetwork
    volumes:
      - /tmp/.X11-unix:/tmp/.X11-unix
      - ../front:/app
    environment:
      - DISPLAY
      - CYPRESS_FRONT_URL=front_test:3000
    depends_on:
      - front_test

Locally it runs fine, but on a GitHub action workflow I get the following error when running
docker-compose run cypress_headless

Your configFile is invalid: /app/cypress.config.ts

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


TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /app/cypress.config.ts
    at new NodeError (node:internal/errors:371:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:87:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:102:38)
    at defaultLoad (node:internal/modules/esm/load:[21](https://github.com/x/runs/7092451542?check_suite_focus=true#step:4:22):14)
    at ESMLoader.load (node:internal/modules/esm/loader:359:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:280:58)
    at new ModuleJob (node:internal/modules/esm/module_job:66:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:297:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:261: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:337:[24](https://github.com/xruns/7092451542?check_suite_focus=true#step:4:25))
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at async loadFile (/root/.cache/Cypress/10.2.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:106:14)
    at async EventEmitter.<anonymous> (/root/.cache/Cypress/10.2.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:116:[32](https://github.com/x/runs/7092451542?check_suite_focus=true#step:4:33))

Above that error is another error, but I don't know if it's related:

libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[192:0628/123716.264172:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
[[19](https://github.com/x/runs/7092451542?check_suite_focus=true#step:4:20)2:0628/123716.276916:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.

My project utilizes TypeScript and here is my /app/cypress.config.ts:

import { defineConfig } from 'cypress'

export default defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
  },
})

I do not have a cypress/index.ts file.

I have tried using both Cypress 10.1.0 and 10.2.0 but neither works. Again, this problem only occurs when running it as a GitHub action.

@morriq
Copy link

morriq commented Jun 30, 2022

The same. but I can locally repeat it.

@benjamin-schneider
Copy link

benjamin-schneider commented Jul 1, 2022

Hello, I had exactly the same problem : everything worked fine locally, I only had the "error unknown file ext..." in github actions.
As a workaround, I updated cypress.config.ts to cypress.config.js and converted the file to javascript :

// @todo : rollback to "ts" file and regular import when issue is fixed
module.exports = require('cypress').defineConfig({
  e2e: {/* ... */}
});

The rest of the files are in regular typescript and it is ok.
Hope it helps

@admah
Copy link
Contributor

admah commented Jul 1, 2022

@benjamin-schneider thanks for posting a temporary workaround. I think #615 could take care of this issue.

@mala-rathinasamy
Copy link

I'm facing the same issue with cypress/included:10.3.1
unfortunately renaming config.ts to config.js doesn't seem to suffice. It now complains of the actual tests being a ts file.

@alucardu
Copy link

alucardu commented Aug 3, 2022

Same here.

@admah
Copy link
Contributor

admah commented Aug 3, 2022

@alucardu we just released an included image last week with global TS support - cypress/included:10.3.1-typescript. Can you try that and see if it closes this issue?

@GarrisonD
Copy link

@admah No, it doesn't work.

It can be easily reproduced:

  1. Create a minimal cypress.config.ts:
import { defineConfig } from 'cypress'

export default defineConfig({})
  1. Try to run Cypress:
docker run -it --rm -v $PWD/cypress.config.ts:/e2e-tests/cypress.config.ts -w /e2e-tests cypress/included:10.3.1-typescript

Output:

libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[193:0804/110550.272823:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
[193:0804/110550.290577:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.
Your configFile is invalid: /e2e-tests/cypress.config.ts

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

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /e2e-tests/cypress.config.ts

....

@GarrisonD
Copy link

This config is also a valid JS code, so I tried to mount it as mjs:

-... -v $PWD/cypress.config.ts:/e2e-tests/cypress.config.ts ...
+... -v $PWD/cypress.config.ts:/e2e-tests/cypress.config.mjs ...

and the error was:

libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[196:0804/110833.296407:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
[196:0804/110833.305132:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.
Your configFile is invalid: /e2e-tests/cypress.config.mjs

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

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'cypress' imported from /e2e-tests/cypress.config.mjs
...

There is nothing to do with TypeScript. The issue is global...

@alucardu
Copy link

alucardu commented Aug 4, 2022

@admah thank you, i've tried that one as well but also didn't work. I ended up with this yml config:

############################
## TEST

test:cypress:
  extends: .base
  image:
    name: cypress/base:14.7.0
    entrypoint: ['']
  stage: test
  script:
    - source .gitlab/scripts/test_cypress.sh
  rules:
    - *branch
// test_cypress.sh
yarn install --frozen-lockfile
yarn add [email protected]
npm run cypress:run:server

@GarrisonD
Copy link

GarrisonD commented Aug 4, 2022

So, the issue is global: missing node_modules in the working dir.

We (users) have two possible solutions here:

  1. Run a super-slow 🐌 npm i/yarn before cypress run that makes cypress/included image absolutely useless 💩
  2. Run a lightning-fast ⚡ ln -s /usr/local/lib/node_modules before cypress run

@coryasilva
Copy link

@GarrisonD
We can at least skip the download of cypress on install with an env var CYPRESS_INSTALL_BINARY=0. But yes, very slow in my pipeline...

@GarrisonD
Copy link

@coryasilva If I planned to run npm i/yarn, I wouldn’t use cypress/included 😆

@deshmaneanup
Copy link

same problem with cypress 10.5.0

@acoreyj
Copy link

acoreyj commented Jan 4, 2023

Happening to me on 10.9 in an NX project

@odoo-ce-modules
Copy link

https://stackoverflow.com/questions/73221655/unknown-file-extension-ts-cypress-config-ts-on-ci/73443680#73443680

This answer from akshayjai1 has 2 down votes on Stack Overflow. No explanation though.

@KalhindiPOA
Copy link

it would be really nice to solve this issue.
@GarrisonD workaround does work but it shouldn't be needed.

we would rather be able to use the cypress/included image as its intended to be. (issue still present in cypress 12.3 image)

@MikeMcC399
Copy link
Collaborator

MikeMcC399 commented Jun 1, 2024

@MikeMcC399 MikeMcC399 added the bug label Jun 1, 2024
@jennifer-shehane jennifer-shehane closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests