When I run npm run cypress:run in my GitLab CI env I get the error:
Your configFile is invalid: //WebApp/cypress.config.ts
It threw an error when required, check the stack trace below:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for //WebApp/cypress.config.ts
test:cypress:
image:
name: cypress/included:10.3.1-typescript
entrypoint: ['']
stage: test
script:
- yarn install --frozen-lockfile
- cd WebApp
- npm run cypress:run
rules:
- *branch
If I run npm run cypress:run from the WebApp folder (where cypress.config.ts is in the root) locally I have no issue. Also no issues when I do an npx cypress:run
However, if I run npx cypress run --config-file WebApp/cypress.config.ts from the parent folder locally I do get the error:
Unknown file extension ".ts"
Any ideas why locally Cypress is working but on the CI the config file is incorrect?
This still seems to be an issues today for LTS 10.10.0
Changing the fresh install cypress.config.ts -> cypress.config.js
and use require like so proved successful.
module.exports = require('cypress').defineConfig({ component: {
devServer: {
framework: "create-react-app",
bundler: "webpack",
},
},
});
I updated this github issue with some more information.
This will be because you have typescript installed globally on your machine so it will work ok locally but not in CI.
Essentially typescript has to be in the folder from where the cypress command is run for it to detect typescript properly.
I went with:
script:
- npm install --global serve
- serve ./build --listen 3000 &
- rm package*
- npm install #percy/cypress typescript
- npm install --global #percy/cli
- percy exec --verbose -- cypress run
Just installing the bare minimum to run the e2e tests ./build is an artifact from another run and percy is really great if you have not used it before.
I am late here, i had similar issue. The del package to delete passed videos was the culprit for me. In the CI environment, it requested to install the del package separately, but in my cypress.config.ts, i was directly able to import del package which was served from third party.
I wanted to install the exact del package in my case and that solved the problem. Del package has its limitations, rimraf solved my issue.
https://www.npmjs.com/package/rimraf
It looks like it's about the version. This might be hepful GitHub
I have tried all different ways suggested in the GitHub issue that
user18025789 linked, but nothing helped. Then I tried switching the config file from .ts to cypress.config.js and it started to work (syntax needed to be updated to JavaScript as well). I have no idea why.
I came across this issue because Typescript was not installed in my Cypress container. When ts-node doesn't have access to typescript, it's require behaves like the native "require", which is why you're seeing the error.
I don't know enough about your specific setup to recommend a solution, but for me I was able to run npm i and mount the volume in the cypress container before running the tests. Another option could be to create a new Dockerfile to extend the base Cypress image with typescript included in the build.
If working on a monorepo and mounting only the app/package folder to test into the cypress docker image, not all dependencies are available within this directory.
To fix this mounting, the whole workspace does the job:
cypress:
image: cypress/included:10.11.0
# …
working_dir: /workspace/app
volumes:
- ..:/workspace
I started facing this issue, suddenly, My solution wasrm -rf node_modules package-lock.jsonnpm i I already had the cypress.config.ts file, so cypress test runner picked it up, when I rannpx cypress open
Related
I have an app initiated using Create React App, so npm run build runs react-scripts build. I recently installed prettier and so added a .eslintrc.json file to the project root to load the prettier plugin. npm run build works as expected locally, but, when deploying the app to Heroku, npm run build tries to run ESLint and fails because the plugins are devDependencies rather than dependencies.
Failed to load plugin 'prettier' declared in '.eslintrc.json': Cannot find module 'eslint-plugin-prettier'
From prior wrangling with a similar issue, I know that I can set NPM_CONFIG_PRODUCTION=false in Heroku so that it will install devDependencies, which actually does resolve the deployment issue. Nevertheless, I'm curious to learn if there's another solution that doesn't require setting NPM_CONFIG_PRODUCTION=false.
Is it possible to prevent npm run build in this scenario from running ESLint altogether or to prevent it from trying to access the plugins specified in .eslintrc.json? I acknowledge that adding .eslintrc.json to .gitignore is one solution, but I want the ESLint configuration in my repo.
you can run "npm run eject" to generate webpack configuration files, and then modify "webpack.config.js",delete the eslint configuration
I have a serverless aws app within a context of many other ones. All of the node_modules are shared in a parent folder, and it works fine with deploys and invoke functions, not with invoke local. This is my structure:
main/
- node_modules
- serverless
- app1
- app2
- serverless.yml
serverless.yml file settings:
package:
include:
- ../../node_modules/**
The problem is whenever I try to run sls invoke local I got a error messages due to package not found. So, the workaround is to npm install --save every package that is outside of my path.
If you have found a solution, not a workaround (like mine) please share :).
It was so obvious I wanted to delete my question, but I'll leave the answer here>
just go to the folder that contains your node_modules, you'll find a package.json there, and run npm install --save for the new packages you need.
cd ../../
npm install --save missing_packages
your serverless.yml include should consider it when running local with no issues.
Violá!
Hi I am Trying to run cypress test through Jenkins and am getting the test form my local m/c not form github and am Executing windows batch command
"./node_modules/.bin/cypress run --spec "cypress\integration\SignUpTestCases\NewUserSignUp.spec.js" in Bulid configuration.
and i am getting this error
C:\Users\akash\CypressAutomation>./node_modules/.bin/cypress run --spec "cypress\integration\SignUpTestCases\NewUserSignUp.spec.js"
The cypress npm package is installed, but the Cypress binary is missing.
We expected the binary to be installed here: C:\WINDOWS\system32\config\systemprofile\AppData\Local\Cypress\Cache\4.4.1\Cypress\Cypress.exe
Reasons it may be missing:
You're caching 'node_modules' but are not caching this path: C:\WINDOWS\system32\config\systemprofile\AppData\Local\Cypress\Cache
You ran 'npm install' at an earlier build step but did not persist: C:\WINDOWS\system32\config\systemprofile\AppData\Local\Cypress\Cache
Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.
Alternatively, you can run 'cypress install' to download the binary again.
https://on.cypress.io/not-installed-ci-error
WHat is the problem here .....or pls tell me about cypress configuration with Jenkins!!!!
Please set up environment variable CYPRESS_RUN_BINARY and its value should be your cypress runner location. (the runner defauly localtion is ~/AppData\Local\Cypress\Cache)
the variable setting:
Name: CYPRESS_RUN_BINARY
Value:C:\Users\Administrator\AppData\Local\Cypress\Cache\4.8.0\Cypress\Cypress.exe
Or you can add the command in the jenkins job:
set CYPRESS_RUN_BINARY=C:\Users\Administrator\AppData\Local\Cypress\Cache\4.8.0\Cypress\Cypress.exe before run the cypress cases.
Your problem probably exists because you have node_modules added to your git repository.
Remove node_modules folder from your repository
add node_modules to .gitignore file.
commit changes, push them and try again.
Could you please give me some advise on how to deal with this issue.
Build Pipeline
npm install
package.json
"dependencies": {
"cypress": "^3.4.1"
}
Release
Powershell command
npm ./node_modules/.bin/Cypress run
The cypress npm package is installed, but the Cypress binary is missing.
2019-10-07T18:04:59.5720120Z We expected the binary to be installed here:
There are some examples on how to cache ~/.npm but nothing seems to work so far. Examples on how to include cypress.io in your vsts are at the building stage and not after release.
According to the error log, it has provided a solution about this. You should run the cypress install command first and then the error will be fixed.
As my test, since I don't have a cypress.json file, so I need run the open command to
automatic generated get the json file and project sample.
Then the open command run as expected.
But because I run the open command in interactive mode and I don't have the cypress.json file in my artifacts, the taks finally failed.
So if you have cypress.json in your repo or artifacts, you just need to add
.\cypress install
in your powershell command.
And if not, you can add the related json file and folder to your repo or artifacts and then the run command will work as your expected.
I recently took over a cypress project; running on windows. The first time I installed, all was working. Now, subsequent to upgrading node/electron/chrome, I can't open cypress with any command. Here's what I tried:
Delete node_modules directory in my project.
npm init Answered with all defaults. node_modules directory is present but empty.
npm install cypress --save-dev (from [the doc][1]). This populated my node_modules, but installed cypress in my account (users) directory.
node_modules\.bin\cypress open That reported:
It looks like this is your first time using Cypress: 3.1.1
Verified Cypress: [in my users dir]
Opening Cypress...
At that point I can see cypress in my process list, but the UI never shows. I can run headless tests normally, so I'm OK from a CI perspective, but I still want to open the UI with my tests locally. I can launch the cypress executable in my user dir and then open my project root directory manually, but can't run an open command normally. The scripts section of package.json doesn't seem to be designed to accept a path to an exe with params.
Is there another way to call open that I'm missing?
Solution: Go to your project directory which you installed cypress, in your package.json update the cypress version to the latest , look at the releases versions link, or just install the latest from cli:
npm install cypress#latest --save-dev
Reopen again and verify:
./node_modules/.bin/cypress open
//OR
npx cypress open
Did you upgrade the Electron version that Cypress uses? Cypress uses Electron 1.8.2 which is significantly behind the latest, and Cypress does not currently support newer versions of electron. See this Github issue for more info.
try starting with debugging enabled:
DEBUG=cypress:* ./node_modules/.bin/cypress open
I can't use command npm to open cypress neither,
but command npx works well.
So you can try this in your visual studio code: npx cypress open
Using this in my code solved the issue
cypress (folder) -->support --> index.ts
add this:
import './commands'
Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from failing the test
return false
})
Didn't work for me as well. I got the same error. I've created new folder in the repo.
Run npm init -y
Run npm install --save-dev cypress
Then go to ./node_modules/.bin/cypress open
And boom the error.
I've workaround it by adding:
{
"scripts": {
"test": "cypress open"
}
}
into package.json
and run cypress with npm run test