Is there a way to add text to unit tests (Jasmine or Mocha) run in Karma - maybe with a console.log - and be able to output it? I understand using result.description (for example) in a reporter, but I don't know of any result.x that I can fill in from the test. I'm not sure, but I think the log4js in Karma cannot be used from the test, as the test runs in the browser and the log4js is on the server?
Related
I must be missing something obvious. I've got a couple of jobrunr jobs where i'm using the lambda enqueue format version 5.1.6. Like this:
JobId jobId = BackgroundJob.<MyService>enqueue(x -> x.doWork());
I would like to validate the plumbing and work in the jobs is executing via some integration tests with Spring, but don't see the options to run now, eager mode, etc? Thanks
You can't, I'm afraid.
You can mock the JobScheduler and capture the args. JobRunr itself is also tested very well so if you pass a job, you can rest assured it will be enqueued.
You could also put the pollIntervalInSeconds to 5 and use awaitility then to verify your job executed. There are many examples of this in the JobRunr repo.
I am trying to run a single set of a single set of tests within the e2e Kubernetes tests. I am quite confused as to how the tests are organized, is there a comprehensive list of all the tests?
Thanks!
Assuming, the tests are placed at ./tests/e2e path in the repository.
If the tests are written in go, they are mostly written using a standard testing library or ginkgo framework.
For running the tests written using standard testing package
Add the tags to a specific test at the start of your test file like,
// +build <my-test>
Run the tests by specifying the tag name, go test -v ./tests/e2e -tags <my-test>
For running the tests written using ginkgo
go test -ginkgo.dryRun ./tests/e2e/... to list all the tests in the package.
go test -ginkgo.focus "<regex>" ./tests/e2e/... to run specific tests mentioned in the focus regex field.
go test -ginkgo.skip "<regex>" ./tests/e2e/... to skip the specific tests mentioned in the regex field
If you have e2e.test binary, you can list all available test by setting following flag: ./e2e.test --ginkgo.DryRun. Then if you want a single test, type: ./e2e.test --ginkgo.Focus="<name of your test>", pay attentention that all special characters in the test name must be escaped. For example, if you want run only conformance tests: --ginkgo.Focus="\[Conformnce\]".
Just in case, the right way of running particularly focused e2e tests is described officially here: https://github.com/kubernetes/community/blob/master/contributors/devel/e2e-tests.md
it would be something like this:
go run hack/e2e.go -- --test --test_args="--ginkgo.focus=${matching regex}"
I am using Protractor for e2e testing, in the protractor config file in the afterLaunch function i am trying to get a list of all the failed specs so that I can send a slack message on the appropriate channel in slack, is there any way to do this?
This is not about Protractor alone, but about the testing framework used under-the-hood. Assuming you are using jasmine, you need to make a custom jasmine reporter and get the result.failedExpectations from the specDone and suiteDone callbacks to get to the expectation failures and check the spec.status in the specDone callback to see if it failed or not.
For the sample reporters, please see:
jasmine-spec-reporter
jasmine-reporters
I am trying to run Karma via node (gulp, specifically) persistently in the background but to manually re-run the tests i.e. I have autoWatch set to false. I start the server with something like:
karma_server = new karma.Server(config.karma)
karma_server.start()
Then elsewhere I would like to trigger the tests running when files are updated outside Karma. The API method that one would expect might work is server.refreshFiles(), but it does not do this.
Internally it seems like executor.schedule() might do the trick, but it seems to be undocumented, private, and inaccessible.
So when autoWatch is turned off, how does one trigger Karma testing with an existing server? I'm sure I must be missing something obvious as otherwise the autoWatch option would always need to be true for the server to be useful.
If you have a server already running you can use the karma runner to communicate with it:
var runner = require('karma').runner,
karmaConfig = {/* The karma config here */};
runner.run(karmaConfig, callback);
The grunt-karma plugin works like this, you can check it out for more info:
https://github.com/karma-runner/grunt-karma/blob/master/tasks/grunt-karma.js
I have a feature that has prod tests to be run on prod server. Its tagged #prod. I have other non-tagged tests that can run in test envs.
In env.rb I have a Before do .. end that opens a new browser and sets up test to run in test env. I also have and a Before('#prod') block that sets up tests helpers to run in prod account.
When I run just the prod test, using cucumber --tags #prod, it runs prod tests. I expect only the Before('#prod') to run. However I see that both the BEfore blocks in env.rb file are run, creating 2 new browser instances and prod test running in second browser window. When my suite of 7 scenarios are done I have 7 blank open browser windows which my test util setup from non-tagged Before.
Given any valid test merchant account # features/step_definitions/ConsumerPortal.rb:1
We are in plain Before
We are in #prod Before
When login to pos portal as 'pos' user
I see the same happening for After tag to logout and close browser as well. Tagged one is run first and then the plain After tag. If I can read what tag a test has in my env.rb Before, I can setup accordingly. Is tehre a way to do this?
Use negation tags with your before tags.
#Before("~#prod")
#After("~#prod")
This will prevent the Before and After tags from running for all #prod tags.
Or else in general, all #Before and #After methods run for any tags.