You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 26, 2023. It is now read-only.
I've added a way to disable fixture teardown by disabling the cleanUp method; a bit messy, but for when fixture generation is expensive, or the environment is complex enough that I want to test a series of things in a persistent environment.
I know not everyone wants this -- there's a lot to be said for small, self-contained specs and contexts, but is there any interest in building such a feature into jasmine-ajax?
varcleanUp;// disable cleanUp() method to persist the fixture across specspersistFixture=function(){cleanUp=jasmine.getFixtures().cleanUp;// save the cleanUp functionjasmine.getFixtures().cleanUp=function(){};// replace it with a fake one}// restore non-persistent fixture behaviorunPersistFixture=function(){jasmine.getFixtures().cleanUp=cleanUp;}
Er, obviously it'd be easier to do in the library itself with a switch instead of the jiggery-pokery above, i just thought I'd share how I did it for clarity.
The text was updated successfully, but these errors were encountered:
For what it is worth, after many hours of troubleshooting a missing jasmine-fixtures element, I stumbled onto the same solution. I have a series of tests which require an initial HTML element to be loaded and subsequent tests interact with the HTML output. I was getting erratic behavior until I realized it was because the jasmine.getFixtures().cleanUp was being called after each it() and describe() call.
It would seem to me the sensible solution is to scope the fixture to the level it was defined. If I create it at the top of my hierarchy of describe & it statements, it persists until that block is completed. That way, if someone wants to load a fixture within a it() statement, it will be cleaned up then. If someone wants to load a fixture in a beforeAll before running all their specs, it will last for that duration.
In the meantime, I will have to use a solution like above to unwire the default behavior.
This appears to be the same issue causing #275 as well.
I always disable the fixture cleanup by overwriting the cleanup method to an empty method, to debug a failed test inside chrome and it helps a lot to reproduce the fail in the actual application just for reproduction.
A kind of easier feature to disable the cleanup would be nice. This is actually a pretty hidden undocumented workaround but it really helps a lot.
Ended up doing a similar thing to decrease test run-time where the overhead of adding and removing elements repeatedly was getting really high.
Our change intercepts clean-up in beforeAll and runs the intercepted clean-up in afterAll before restoring the clean-up functions. A public API exposed to do this would be nice.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I've added a way to disable fixture teardown by disabling the cleanUp method; a bit messy, but for when fixture generation is expensive, or the environment is complex enough that I want to test a series of things in a persistent environment.
I know not everyone wants this -- there's a lot to be said for small, self-contained specs and contexts, but is there any interest in building such a feature into jasmine-ajax?
Er, obviously it'd be easier to do in the library itself with a switch instead of the jiggery-pokery above, i just thought I'd share how I did it for clarity.
The text was updated successfully, but these errors were encountered: