Merge branch 'bonkevin-fix-custom-matcher'
* Fixes custom matchers in top-level specs * Merges #2088 from @bonkevin
This commit is contained in:
@@ -11514,7 +11514,10 @@ getJasmineRequireObj().TreeRunner = function(j$) {
|
||||
_executeSpec(spec, specOverallDone) {
|
||||
const onStart = next => {
|
||||
this.#currentRunableTracker.setCurrentSpec(spec);
|
||||
this.#runableResources.initForRunable(spec.id, spec.parentSuiteId);
|
||||
this.#runableResources.initForRunable(
|
||||
spec.id,
|
||||
spec.parentSuiteId || this.#executionTree.topSuite.id
|
||||
);
|
||||
this.#reportDispatcher.specStarted(spec.result).then(next);
|
||||
};
|
||||
const resultCallback = (result, next) => {
|
||||
|
||||
@@ -2277,6 +2277,34 @@ describe('Env integration', function() {
|
||||
await env.execute();
|
||||
});
|
||||
|
||||
it('Custom matchers set in top-level beforeAll should be available to all specs and suites', async function() {
|
||||
const matchers = {
|
||||
toFoo: function() {}
|
||||
};
|
||||
|
||||
env.beforeAll(function() {
|
||||
env.addMatchers(matchers);
|
||||
});
|
||||
|
||||
env.describe('suite - top-level', function() {
|
||||
env.it('has access to the custom matcher', function() {
|
||||
expect(env.expect().toFoo).toBeDefined();
|
||||
});
|
||||
|
||||
env.describe('suite - nested', function() {
|
||||
env.it('has access to the custom matcher', function() {
|
||||
expect(env.expect().toFoo).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
env.it('spec - top-level - has access to the custom matcher', function() {
|
||||
expect(env.expect().toFoo).toBeDefined();
|
||||
});
|
||||
|
||||
await env.execute();
|
||||
});
|
||||
|
||||
it('throws an exception if you try to create a spy outside of a runnable', async function() {
|
||||
const obj = { fn: function() {} };
|
||||
let exception;
|
||||
|
||||
@@ -47,7 +47,10 @@ getJasmineRequireObj().TreeRunner = function(j$) {
|
||||
_executeSpec(spec, specOverallDone) {
|
||||
const onStart = next => {
|
||||
this.#currentRunableTracker.setCurrentSpec(spec);
|
||||
this.#runableResources.initForRunable(spec.id, spec.parentSuiteId);
|
||||
this.#runableResources.initForRunable(
|
||||
spec.id,
|
||||
spec.parentSuiteId || this.#executionTree.topSuite.id
|
||||
);
|
||||
this.#reportDispatcher.specStarted(spec.result).then(next);
|
||||
};
|
||||
const resultCallback = (result, next) => {
|
||||
|
||||
Reference in New Issue
Block a user