Repository navigation
test: run the test app on Jasmine 7 #2105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+329
−3,415
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
285e9df
test: bump shared tests to common-runtime-tests-app master
edusperoni fb27d9d
test: run the test app on jasmine-core 7 from npm
edusperoni 8716c50
test: make the test app's specs pass on Jasmine 7
edusperoni b3961a7
test: drop GC specs that assert full marking-mode reachability
edusperoni 6174596
test: harden the Jasmine run against restarts and startup failures
edusperoni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| "dayjs": "^1.11.7", | ||
| "eslint": "^9.15.0", | ||
| "globals": "^15.12.0", | ||
| "jasmine-core": "7.0.2", | ||
| "semver": "^7.5.0" | ||
| } | ||
| } | ||
57 changes: 57 additions & 0 deletions
57
test-app/app/src/main/assets/app/Infrastructure/Jasmine/boot.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // Boots jasmine-core for the test app. The test-runner-deps plugin | ||
| // (test-app/test-runner-deps) stages jasmine-core from the repo's node_modules | ||
| // into ./vendor at build time. | ||
| var jasmineCore = require("./vendor/jasmine-core/jasmine"); | ||
| var JUnitXmlReporter = require("./jasmine-reporters/junit_reporter").JUnitXmlReporter; | ||
| var TerminalReporter = require("./jasmine-reporters/terminal_reporter").TerminalReporter; | ||
|
|
||
| jasmineCore.installGlobals(global); | ||
|
|
||
| var env = jasmine.getEnv(); | ||
|
|
||
| env.configure({ | ||
| // Suites carry state from one spec to the next (the shared Workers suite | ||
| // counts live runtimes across its specs), so they run in declaration order. | ||
| random: false | ||
| }); | ||
|
|
||
| // jasmine-core's pretty-printer falls back to value.toString() for tagged objects | ||
| // it does not recognize, which throws for null-prototype ones such as module | ||
| // namespaces. toBe() builds its message even when it passes, so without this an | ||
| // expect(namespace).toBe(sameNamespace) throws. | ||
| beforeEach(function () { | ||
| jasmine.addCustomObjectFormatter(function (value) { | ||
| if (value !== null && typeof value === "object" && typeof value.toString !== "function") { | ||
| var tag = Object.prototype.toString.call(value); | ||
| if (tag !== "[object Object]") { | ||
| return tag; | ||
| } | ||
| } | ||
| return undefined; | ||
| }); | ||
| }); | ||
|
|
||
| env.addReporter(new TerminalReporter({ | ||
| verbosity: 2 | ||
| })); | ||
| env.addReporter(new JUnitXmlReporter()); | ||
|
|
||
| // Without a results file the runtests harness only gives up after its full | ||
| // timeout, so a run that cannot start still writes one failing testcase. | ||
| function saveRunFailure(message) { | ||
| var xml = '<?xml version="1.0" encoding="UTF-8" ?>\n<testsuites>' + | ||
| '\n <testsuite name="Jasmine run" hostname="localhost" time="0" errors="0" tests="1" skipped="0" failures="1">' + | ||
| '\n <testcase classname="Jasmine run" name="(run could not start)" time="0">' + | ||
| '\n <failure type="exception" message="Jasmine could not run the suite">' + | ||
| '<![CDATA[' + message.replace(/\]\]>/g, ']]]]><![CDATA[>') + ']]>' + | ||
| '\n </failure>\n </testcase>\n </testsuite>\n</testsuites>'; | ||
| global.__JUnitSaveResults(xml); | ||
| } | ||
|
|
||
| exports.execute = function () { | ||
| env.execute().catch(function (e) { | ||
| var message = String((e && e.stack) || e); | ||
| console.log("Jasmine could not run the suite: " + message); | ||
| saveRunFailure(message); | ||
| }); | ||
| }; | ||
29 changes: 29 additions & 0 deletions
29
test-app/app/src/main/assets/app/Infrastructure/Jasmine/globalErrorSpy.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Wraps a done-style spec body that raises global `error` events or unhandled | ||
| // rejections on purpose. Jasmine fails the running spec on those unless its | ||
| // global error spy is installed, which it is for as long as the body runs; the | ||
| // spy is passed as the body's second argument. Jasmine's spy never cancels the | ||
| // event, so listeners, preventDefault() and the __onUncaughtError fallback behave | ||
| // as they do in production. | ||
| // | ||
| // The body must call done() only after every error it expects was dispatched: | ||
| // one that arrives later is charged to whatever spec is running then. | ||
| exports.raisesGlobalErrors = function (body) { | ||
| return function () { | ||
| var context = this; | ||
| return jasmine.spyOnGlobalErrorsAsync(function (globalErrorSpy) { | ||
| return new Promise(function (resolve, reject) { | ||
| function done(reason) { | ||
| if (reason === undefined) { | ||
| resolve(); | ||
| } else { | ||
| reject(reason instanceof Error ? reason : new Error(String(reason))); | ||
| } | ||
| } | ||
| done.fail = function (reason) { | ||
| done(reason === undefined ? new Error("Failed") : reason); | ||
| }; | ||
| body.call(context, done, globalErrorSpy); | ||
| }); | ||
| }); | ||
| }; | ||
| }; |
139 changes: 0 additions & 139 deletions
139
test-app/app/src/main/assets/app/Infrastructure/Jasmine/jasmine-2.0.1/boot.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.