I try to run npm test in Github Action, but it just stuck there forever. I can see that the tests are completed successfully in very short time, so I have no idea why it is not terminating
This is the test script in package.json
"test": "react-scripts test --watchAll --coverage --forceExit --transformIgnorePatterns \"node_modules/(?!axios)/\"",
You can try removing the --watchAll flag from the test script to see if that helps. The script should then run the tests once and exit when they are completed.
It's possible that the --watchAll flag is causing the test script to stay running indefinitely.
Related
I'm trying to set up a pipeline on Azure DevOps with Cypress tests.
Locally test output file is created correctly.
I'm using npx cypress run command
I'm getting an error/warning for Publish Test Results:
##[warning]No test result files matching **/test-output-*.xml were found.
Here is my cypress.json file:
{
"reporter": "junit",
"reporterOptions": {
"mochaFile": "tests/test-output-[hash].xml",
"toConsole": true,
"attachments": true
},
"video": false,
"pluginsFile": "cypress/plugins/index.js",
"supportFile": "cypress/support/index.js"
}
Here is azure-pipelines.yml:
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- develop
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool#0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install
displayName: 'npm install'
- script:
npx cypress run
displayName: 'Execute cypress tests'
- task: PublishTestResults#2
displayName: "Publish Test Results"
condition: always()
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/test-output-*.xml'
searchFolder: '$(System.DefaultWorkingDirectory)'
- task: PublishBuildArtifacts#1
condition: always()
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
I tried to do all weird stuff, but nothing helps.
Checked all StackOverflow topics like those below:
Azure DevOps test -xml not found after running the Cypress tests
Is there any way to show Cypress Test Results in Azure DevOps Test Results Tab?
Azure DevOps test -xml not found after running the Cypress tests
No test result files were found using search pattern '...\**\TEST-*.xml
Cypress Integration with DevOps
All is looking to be set up correctly according to Cypress documentation and blogs etc.
Maybe test output file is not created on Azure?
Maybe someone has a clue?
EDIT:
I checked using ls -al command, that tests folder is not created.
But even if I created it using mkdir tests before starting cypress the folder is empty after the cypress job.
So Cypress is not creating test output report. Why locally the file is created but on Azure no?
Please check with the following steps:
Set the pipeline variable system.debug to be true, and run the pipeline again.
After the step "Execute cypress tests" is completed, check if you can get more details for troubleshooting from the debug logs on the console window.
You mentioned that the same npx cypress run command can work fine on your local machine, please try to install a self-hosted agent on your local machine to run the pipeline to see if the problem still exists.
If the problem still exists, for us to investigate this problem further, please share the complete logs of the test step with us.
Just had the same issue. Had my artifact download task set on a specific build, so I never get the new build with the correct cypress.config file. Updated the build target and now everything is working. So thanks #DuduA, I thought I'll just answer it so it's a bit easier to see if someone has the same issue.
Please add a command line task to check if cypress run command is running at which folder.
I think you might be running the cypress command in wrong folder. The issue will be resolved if you will provide the correct folder structure and run cypress run command where cypress.json file exists.
Also in cypress.json file check the path of plugins file and support file.
Don't know if this is possible, but I'd like to add a button to an angular 6 page that runs the e2e scripts (i.e. "npm run e2e"). The idea is to have an easy way for the PO's to run the e2e tests. The e2e tests are written in testCafe. Is this possible?
I found these but it's not quite what I'm looking for
how to run protractor test from UI or web interface - just select scenario from github and run
How to run a protractor test from a UI against an angular app
A browser cannot execute any npm script.
The simplest solution would be to install a batch file on the PO's computer that will do in sequence:
git clone < e2e-repo >
cd < e2e-repo >
npm install
npm run e2e
I'm having an odd issue with the awsebcli package when running it on Gitlab's pipeline CI system.
When I run eb deploy locally, the command succeeds (or fails) much as expected. When I run it as part of the CD scripts I've written, it runs successfully (i.e. returns an exit code of 0) but doesn't actually trigger the deployment. No errors are returned - in fact there's no text output from the command at all.
Can anyone suggest what could be going wrong here?
I am on freeCodeCamp, have reached this challenge. I have completed installing NPM, started a project and installed a module too, but I am stuck at NPM TEST which says:
Now you've installed something, and used npm ls to show what's going on. If you look at the package.json file, it has this rather odd bit in it:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
npm can be used as a task runner, and almost every module and project
will have a test script that runs to make sure everything is good. In
order to help remind you to do this, npm puts a "always failing" test
in there by default.
First, create a file called test.js. It doesn't have to do anything,
really. (This is npm class, not testing class.) But it has to exit
without throwing an error, or else the test fails.
Then, edit your package.json file to make your scripts section look like
this instead:
"scripts": {
"test": "node test.js"
},
Once that's done, run how-to-nom verify to check your work.
I tried couple of things I got online to create test.js, but I am not sure how to proceed further.
All you have to do is create an empty test.js file and edit your package.json file. Chances are you missed this step.
In order to pass the test, you need to update the echo \"Error: no test specified\" && exit 1 line with node test.js. As it is an empty file, it won't throw any error and once you run the how-to-npm verify command it will pass.
My NAnt builds run fine locally on a developer machine, and locally on the command line of the Hudson server, but they will not run in my configured Hudson project.
The console output when I run a Build via the Hudson web UI is similar to the following :
Started by user anonymous [workspace]
$ sh -xe
C:\WINDOWS\TEMP\hudson8104357939096562606.sh
C:\WINDOWS\TEMP\hudson8104357939096562606.sh:
fork failed: no error [1] Archiving
artifacts Finished: SUCCESS
I have another project configured properly that runs fine so I know the NAnt plugin is setup properly in Hudson, and that NAnt is on the system path.
Can anyone suggest possible causes as to why this build won't run?
The problematic build may be configured to Execute a Shell script, rather than Execute a Windows Batch file.
Copy the command from the existing build step (the Execute Shell Script) and remove the step. Then add a new step to Execute a windows Batch File and paste the command.
Trigger the build and observe the results.
(I asked and answered this since it took me quite a while to figure out how I had mis-configured this particular build. Hopefully it'll save time or give ideas to other people trouble-shooting automation..)