Jest tests not seeing the test files in "Vanilla Static" template - codesandbox

I haven't successfully used jest tests in codesandbox before, but I heard it was zero config. I am trying now in this "Vanilla Static" template:
https://codesandbox.io/s/lr74k637mq
I created a PathStore.test.js - however the test console is never picking it up. Is there some configuration I have to do?
I thought to add "jest" as a dependency, so I did that, but its still not working.

Related

Citrus Framework - echo action does not "echo"

I am attempting to debug/trace an integration test written with the Citrus Framework. Among the various test "actions" that can be taken, there is an echo action which is supposed to do what you might expect: echo something to the console log. The problem is: it does not echo.
When I run the integration test (via Maven failsafe plugin), errors from the test failing appear on the console, but nothing else.
What am I missing?
UPDATE:
This appears to only be a problem when running the integration tests as part of a maven build. When the test is run from eclipse, the complete console log appears.
This may be an issue with your test names. Failsafe Maven plugin by default has a naming convention and only runs those tests that follow this convention. So your test names must match a pattern.
Please review the default naming pattern in failsafe plugin and see if this fixes your issue.
I was able to figure out how to get logging to capture the Citrus integration test console output. See related issue Citrus Framework logging - how to enable/use.

VS Code Extension tests not found on Azure Pipeline

I have an extension, initially created using the standard yo code template, and successfully uploaded to the market place. I have created a test suite, which works correctly when running locally (i.e. pressing F5), and I now wanted to add CI testing to the Github repo.
I followed the instructions on Continuous Integration and created a config file. The extension now builds successfully, however it appears that no tests are discovered.
For example, in this build I intentionally introduced a failing test, but it still passes.
Is there a step I'm missing or a good way to debug the problem?
See the Issue I opened for the answer. Currently, the tests fail silently if you do not have the required dependencies listed.

example using beforeMiddleware & webpackBlocker in a karma.config.js file

i've got a karma-webpack2-qunit setup with babel loader working. es6 is used for both src and test js files.
when running karma in autowatch mode, any changes to source files are detected and karma re-runs the test suite again but the changes are not picked up.
based on this note from the webpack-karma integration page: webpack-karma middleware info , this seems like the config option i need to get the setup fully working.
"This loader provides a webpackBlocker middleware that will block tests from running until code recompiles."
i can't find any examples of using the webpackBlocker configuration.
does someone have a working config they can share?
here's what i'm using in karma.config.js:
the karma test suite is working still but code changes to source or test code do not get reflected in the next run.
i finally got this working. had a mismatch in my "files" pattern config for my test and source files including the "context" object.
now when i modify either test or source js files, the code is compiled first and the tests are rerun in autowatch mode. yay !!!
will post the full working solution to a GitHub repo in case anybody else wants to get the same "unholy" :-) combination (karma + qunit + webpack + es6 + mocha reporter + phantomjs) working. will also add linting.

How to test a Sails.js app using Jest instead of Mocha?

The documentation for Sails 0.12.11 explains how to set up testing using the Mocha framework. I would like to use Jest to do that.
I tried using the same code for bootstrap.test.js, but replacing before with beforeAll and after with afterAll; replacing this.timeout(5000) with jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000. Because Jest expects at least one test in a file, I made a dummy test there to make sure it did not complain.
Then, in another file (some.test.js), I tried to reference a dummy service that I created just to see if things work. With Mocha, any Sails service should be available by default, without any require statement.
it('should call the dummy service fine', () => {
expect(DummyService.doSomething()).toBe('ok');
});
Upon running the tests with jest tests/*, I come across the following log:
Furthermore, the dummy service test fails because it says it is not defined.
FAIL tests/some.test.js
● should call the dummy service fine
ReferenceError: DummyService is not defined
Jest does seem to be well suited to tests sails.
Jest philosophy is to have many tests running concurrently with independent state this means jest has no way to use global setup file.
Using jest for sails would mean :
Starting an instance of sails per test which could be memory hungry if you've got many test.
Customize its orm (waterline) so that it uses a random file for the database for each test instance to accomplish clean state.
Now you may argue that sails does it wrong and could be made from the startup to support the kind of testing jest promote.
I hope this is still relevant.
I won't lie you. It was not easy :(. It took me all the day but after all I was able to configure
Eslint
Prettier
Jest
check how it all works in my repo and feel free to contact me if you have any doubt.
https://github.com/tugorez/sails-jest

Structuring webpack config for use with karma testing

I would like to create a test suite which will be run with karma against my app which is using webpack to build itself. I have two entrypoints, app and vendors. These are set up through my webpack.config.js file here. The resulting bundle.js should contain both of these entrypoints in its generated file.
My karma (mocha) tests residing in test/spec/*_spec.js are currently pointing to specific components, via require statements like:
var app = require('../src/scripts/App')
They also utilize react/jsx which seems to be causing problems during the test run where I get jsx errors:
Module parse failed: /Users/dmarr/src/status/test/spec/app_spec.js Line 10: Unexpected token <
You may need an appropriate loader to handle this file type.
I'd like to keep test runs quick as possible as well as fast build times for testing with webpack-dev-server during development by minimizing babel transforms to only where needed.
What do I need to do in karma.conf.js to get my builds working? Here is the karma.conf.js file I'm playing around with.
Note, that I do have this working without breaking out the vendor bundle here: https://github.com/bitwise/status
Thanks for any help,
Dave
In a similar setup, disabling CommonsChunkPlugin (for testing only) worked for me. Give it a shot!