Junit output for Jasmine 3.x - junit

I'm trying to run tests in jasmine and have them output a junit file. I've seen npm install -g jasmine-xml-reporter but that seems to only be for jasmine 2.x. Is there a way to run tests in jasmine 3.x and have the junit output?
I'm using jasmine as the test runner itself.

Related

CircleCI is unable to read the JUnit xml generated by Behave while splitting the test by timings

Ok, so I am trying to split my Appium tests by their timing in CircleCI for running the test in parallel. My tests are written in behave(Python) and I am generating the JUnit XML file. Here is my config.yml file
version: 2.1
orbs:
macos: circleci/macos#2.2.0
jobs:
example-job:
macos:
xcode: 13.4.1
parallelism: 4
resource_class: large
steps:
- checkout
- run:
name: Install appium server
command: |
sudo npm update -g
sudo npm install -g appium
sudo npm install -g wd
- run:
name: Start appium server
command: appium --address localhost --port 4723
background: true
- run:
name: Installing Dependencies
command: pip3 install -r requirements.txt
- run:
name: Test application
command: |
TEST=$(circleci tests glob "features/featurefiles/*.feature" | circleci tests split --split-by=timings --timings-type=classname)
echo $TEST
behave $TEST --junit
- store_test_results:
path: reports
- store_artifacts:
path: ./Logs
destination: logs-file
- store_artifacts:
path: ./screenshots
workflows:
example-workflow:
jobs:
- example-job
When I am running the test, I am getting the error "No timing found for "features/featurefiles/XXX.feature" and it is splitting the test by the filename. It runs well but the split is not happening by the timing.
When the execution is done, I can see the data in the TESTS tab, also in the Timing Tab
I believe CircleCI is not able to read the JUnit file generated by Behave, it is searching for the different JUnit XML file. How can we make CircleCI read the JUnit file generated by Behave?
If anyone face such issue, please take a look at the classname in the JUnit report. There is a format in which CircleCI read the classname. In my case, the classname in the JUnit report was mentioned as
features.featurefiles.Login.feature
But the CircleCI was looking for the classname in below format
features/featurefiles/Login.feature
I had to write a utility to change the classname in the report once the execution was completed.Once it was done, CircleCI was able to read the timings.
Hope it help someone :)

Transpilation of ES6 for unit tests

I am using babel to transpile my JS using Aurelia framework but ES6 unit tests execute during the deployment process - I need them to run before we get to deployment so that I can validate or address issues beforehand. Anyone run into transpilation issues while trying to run js jasmine unit tests?

can an npm script be run from the UI

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

RSpec report failure outside tests to JUnit

How do I configure rspec to report the absence of examples as a failure in the JUnit report?
To give you some context: I recently parallelized my rspec test suite using parallel_rspec. Doing so, I forgot to migrate a --require XYZ from the .rspec file to .rspec_parallel. As most of my specs started with require 'XYZ' on their own, I didn't notice the error right away. If one of the runners starts with a spec that does not have that include, it fails for some symbols not being defined (see here). However, the generated JUnit reports just state that there was no test being executed so that failing workers went unnoticed in our Jenkins.
I am quite certain that the lacking --require flag was breaking the runner, but I would like to catch if that should not have been the single cause. Therefore, how would I configure rspec to report "no tests" as a failure when using --format RspecJunitFormatter --out tmp/rspec.xml?
$ rspec --version
RSpec 3.7
- rspec-core 3.7.1
- rspec-expectations 3.7.0
- rspec-mocks 3.7.0
- rspec-support 3.7.1

Selecting specific tests to run in gradle

I'm trying to fix our messy failing test runs, and, unfortunately, I'm very new to gradle. We currently have testng, junit, and I'd like to add some spock tests to the mix as well. I'm not quite sure how gradle determines which tests to run when I type "gradle test". How can I prevent the testng &/or junit tests from running? How can I get gradle to start running my spock tests?
By default, the test task runs all JUnit tests it can find, which includes any Spock tests. To make it run TestNG tests instead, configure the task as follows:
test {
useTestNG()
}
If you have both JUnit and TestNG tests, you need two test tasks, one for each test framework.
To run a subset of tests, use the -Dtest.single system property. For more information, see the corresponding section in the Gradle User Guide.
You may provide using the command line:
$> gradle test --tests org.somewhere.MyTestClass
Or even
$> gradle test --tests org.somewhere.MyTestClass.my_test_case
$> gradle test -Dtest.single=YourTestClass