SailsJS Model.query() undefined in test - sails.js

I find that when I call Model.query in a Mocha test, its undefined. Model.find/create etc works. Model.query works when the app runs normally. Why might that be? I am using sails-postgresql
In my mocha test bootstrap I have already lift sails.

Related

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

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.

How do I make a Karma compliant test harness for the browser?

My guess is that the Karma test runner does not hook in Mocha and Jasmine, rather the reverse.
so I assume Mocha and Jasmine call something like this:
window.__karma__.testCasePassed(data);
window.__karma__.testCaseFailed(data);
and then Karma will report these events.
I am writing Suman and I want to figure out if I can make Suman Karma compliant.
When I look through the Mocha and Jasmine codebase however, I am not seeing the evidence I am looking for.
You won't find anything in the code of Mocha or Jasmine themselves as they don't know anything about Karma. When you use Mocha and Jasmine in Karma you have to use karma-mocha and karma-jasmine. These are the packages that bridge Mocha and Jasmine on the one hand, and Karma on the other.
If you look at karma-mocha, you'll see that it has a function called createMochaReporterConstructor which creates a Mocha reporter that calls function on window.__karma__. (You can see it called here and the first argument is window.__karma__.)
There is a bit of documentation about the Karma framework API on this page (search for "Karma Framework API" to get to it). It is a very brief description though. If it were me, I'd look at the code of karma-mocha and karma-jasmine to have a better idea of how to use it.

how to generate logs using log4js-protractor-appender in angular/cli project using typescript

i have tried using log4js-protractor-appender for e2e testing using protractor in angular cli project by following link Writing a log file for Protractor/Jasmine tests without using command line
I think you should use jasmine or mocha for reporting your test results. Hope it will help you. How can I save protractor test results

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

Protractor/cucumberjs rerunning failed tests/cucumber features/specs

Given that automated UI tests sometimes fail due to flakiness, an ability to rerun only the failed tests becomes incredibly useful in a framework like protractor.
Unfortunately, as of 09/13/2016, there's no way to rerun failed tests with protractor.
How do you guys rerun your failed tests? Ideally, I'd like suggestions/ideas from people using the javascript implementation of cucumber, cucumberJs.
There's protractor-flake that was developped by Nick Tomlin to address this problem but that module doesn't always work when dealing with multicapabilities where you're trying to run your tests in parallel.
A. How do you guys rerun your failed tests? Ideally, I'd like suggestions/ideas from people using the javascript implementation of cucumber, cucumberJs.
There's protractor-flake that was developped by Nick Tomlin to address this problem but that module doesn't always work when dealing with multicapabilities where you're trying to run your tests in parallel.
There's protractor-flake that was developped by Nick Tomlin to address this problem but that module doesn't always work when dealing with multicapabilities where you're trying to run your tests in parallel.
This question: How to rerun the failed scenarios using Cucumber? almost answered the question; problem is: how do I use that command (cucumber -f rerun --out rerun.txt) to rerun my tests AND run protractor in parallel? That command might only work when you're not parallelizing your protractor tests;
B. How would you use that cucumber command to run your tests in parallel?
Please answer question A and B above, thanks again!
So far I have found the following tool, protractor-flake, that will rerun failed protractor tests:
***Github***: https://github.com/NickTomlin/protractor-flake
***NPM***: https://www.npmjs.com/package/protractor-flake