Testing web extension in CI with cypress - google-chrome-extension

I want to add E2E tests to my web extension, using cypress, and run them on a CI.
Is that even possible?
The tests pass locally on $ cypress open, but fail on $cypress run
The extension adds an element to the dom and cypress can't find it (the extension doesn't seem to get loaded in headless mode)
Here's a reproducible repo with the most simple one line test:
https://github.com/goldylucks/cypress-test-tiny

Related

Code coverage for Chrome Extension e2e testing

I am using WebdriverIO / mocha for the e2e automation testing of Chrome Extension. So, I wonder is there any way to do a code coverage e.g. by instrumenting a code using nyc tool? If yes, what would be the proper way to do so given that my Chrome extension source code in ./src and it is built to a webpack bundle in /.dist folder (which is then loaded in Chrome browser). Is ./src or a ./dist folder should be instrumented in that case?
Thanks in advance for any hint :)
I have also tried the devtools service which is part of WebdriverIO, but its code coverage feature does not work at the moment, because of the known bug.

how to sinc VSC and Cypress

I am having problem with syncing changes on my test that I made in VSC and running it in cypress.
When I make change in test in VSC and open cypress and run it, in Chrome appears old test with no changes
Change was made in VSC and saved
Test is running without change

How would I setup bamboo unit testing that runs both karma and jest

I have been trying to set up server-side testing for my application but have run into an issue with bamboo recognizing more than one test type. In the past, it worked just fine using only karma as the unit test, but I need to add server-side testing which works much better with jest.
The main problem I am running into is that when both are run as shown below the coverage report is only created for the karma(unit) tests.
test-unit=npm run test:unit && npm run test:server
I have also tried running jest under bamboos test-e2e and test-contract-test but when I do this nothing is reported. So is there a way to set up server-side testing separately in the .bamboorc file
So, I found an answer!
In the .bamboorc file move the test-unit = npm run test:unit to the end of the file and for the first test use
test-contract-consumer=npm run test:server -- --collect-coverage
This should then collect the coverage for the server tests in bamboo under the contract tests consumer artifacts, and the karma unit test should still show up under the unit test coverage artifacts.

mocha sidebar is not showing tests

I'm developing a very simple typescript project and I added a very tiny test with mocha. I installed mocha sidebar on VS Code and all it's dependencies, but test are not showing in the left panel.
The strange is that when I press debug button, my test run without problem (?)
I want to distribute this package on NPM, and only distribute .js, .d.ts, js.map and d.ts.map files.
I think the problem is in my project.json, but I cannot figure what is it. The source code is here
The only change I needed was in the VS code workspace settings: Under extensions I pointed the 'mocha glob files'-setting to my test scripts
One thing that I notice from your repo is you have package.json, test folder and another src folder inside type-exception/src.
I can run the mocha sidebar plugin successfully.
My solution is to open the project in vscode from the type-exception/src folder not type-exception folder.
My file structure
My mocha sidebar
I also saw that you have correct vscode workspace settings that set mocha files to
{
"mocha.files.glob": "lib/test/**/*.js"
}
Hope it helps
I had the Testing view showing Jest tests and realised that for Mocha I needed to install another VSCode Extension called "Mocha Test Explorer": https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-mocha-test-adapter
Once installed I created/edited a .vscode/settings.json file in my project folder and added the following clues to tell Mocha to find my tests under the tests folder:
{
"mochaExplorer.files": "tests/**/*.ts"
}

Run test cases and on Success deploy - React JS App with Jenkins

I am trying to run test cases and deploy React-js app with Jenkins.
I am able run react-js app locally after git push command, but after that second command mocha (command to run test cases) is never executed.
I want to deploy react-app to production if all test cases passes.
Below is my simple build script
cd naviaget/to/package.json/file
npm start
mocha
Any help is appreciated.
Well if npm start is starting the development server, you shouldn't call it before running the scripts, because the server won't finish execution until it's closed. That's the reason mocha is never executed.
Normally in CI you first run your tests, and then if everything goes fine you deploy, run a server, whatever. These are normally two different steps: integration (running your test) and deployment (spinning up your server).
I'm not familiar with Jenkins but I'm pretty sure it should be easy to set it up like that:
Run the tests with mocha
If everything is fine, re-reploy

Resources