Comments (3)
👍
from gulp-jasmine.
The issues, explained
I spent several hours yesterday taking a look at the updates in this branch and how the gulp-jasmine tests interact with the Jasmine 4 engine. Here's what I found:
-
For performance reasons, Jasmine engine is using a Singleton pattern for its environment. It doesn't matter how many times you call
new Jasmine(options)
, you will get the same instance unless you force a shutdown in between. -
By setting
jasmine.exitOnCompletion = false
, you are disabling the shutdown. (A premature shutdown can prevent promises from completing, so it's an engineering workaround on their end.) -
Each spec file is represented as a "suite" of tests internally. Duplicate files are skipped to avoid duplication of effort, resulting in overall status of "incomplete" from the engine. (IMO: "skipped" might have been a better choice.) You know this has happened when you get the following verbose output.
Running 0 specs. 0 specs, 0 failures. Finished in 0 seconds.
-
And here's the gut punch: The Jasmine engine returns one "overall status" for all suites combined.
- This happens asynchronously, no matter which spec file you think you are running. So, even if the current spec passes all tests, the engine might still return an overall result of "failed."
- The information returned from
execute
does not tell you which suite caused the failure, so you'd have to crack open the engine to map failures correctly.
I know the Jasmine folks have deprecated engine shutdown, but without a granular way to determine which part of the suite is reporting errors, this seems premature IMO. (This might have changed in Jasmine 5 alpha, more investigation needed.)
Why this matters
None of these changes would matter if all the gulp-jasmine
tests were designed to pass, but this is not the case. The fail-fixture.js
is specifically designed to test what happens when tests fail. (Excellent choice, BTW.)
NOTE These issues are not likely to impact regular users of
gulp-jasmine
as test failures generally should be reported.
- The
ava
tests are assuming that each fixture is run in isolation. (False.) - Only the failure tests are configured to ignore errors. (Failure are reported across the entire suite.)
- Files are submitted multiple times to test different features. (Duplicates are skipped.)
Some architectural suggestions
In order to run a comprehensive suite of tests for gulp-jasmine
, you might consider the following suggestions.
-
Allow the caller to customize the default "exitOnCompletion = false" setting, making it possible to require a shutdown between invocations of the
gulp-jasmine
pipeline. Then, enforce a shutdown betweenava
tests. -
Write a second
ava
suite to run thefail-fixture.js
tests separately from those that succeed. Manually restart Jasmine engine between these twoava
suites.
A note about promise rejection
Finally, just a reminder that await
will throw when a promise is rejected for any reason. The code in index.js
is wrapped in a try/catch, but the catch handler turns around and sends a PluginError
back to the flush callback, causing a secondary "unhandled exception" in the transform pipeline. This might be the desired effect for production pipelines that need to crash when a test fails, but it begs the question how to detect these edge cases more gracefully in the ava
tests.
- Add setting to configure pipeline to return 'jasmineError' events rather than
PluginError
exceptions. This would allow the pipeline owner to more gracefully detect and respond to pipeline failures caused by rejected promises.
from gulp-jasmine.
If anyone wants to work on this, see the initial attemp in #106
from gulp-jasmine.
Related Issues (20)
- Unable to give references of file needed in specs from gulpfile.js
- Issue DEPRECATION : Setting randomizeTests directly is deprecated, please use the random option in `configure`
- Update Jasmine to 3.4 HOT 2
- issues with require caching HOT 4
- export jasmine object HOT 9
- Replace silent reporter with onComplete callback
- Error trying to use config in Node 6
- Broken with Jasmine 2.5.0? HOT 9
- Config option for custom Jasmine-instance HOT 4
- gulp-jasmine runs the tests twice when Jasmine version is 2.5.2 HOT 3
- Tests that should fail pass using gulp-jasmine HOT 1
- jasmine doesn't seem to run HOT 1
- Jasmine never getting called if over 16 files loaded HOT 2
- jasmineDone event not called when tests fail
- process exits with exit code 0 when tests fail HOT 3
- Cannot load module using require.
- deleteRequireCache blows the stack for circlular referenced files HOT 3
- MaxListenersExceededWarning: Possible EventEmitter memory leak detected. HOT 1
- Running a focused test throws an error when it shouldn't. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-jasmine.