Configurable spec/suite filename detection
* Adds extraItStackFrames and extraDescribeStackFrames config properties. * Un-deprecates the filename properties of reporter events. * Fixes #2065.
This commit is contained in:
@@ -13,7 +13,9 @@ describe('Configuration', function() {
|
||||
...standardBooleanKeys,
|
||||
'seed',
|
||||
'specFilter',
|
||||
'verboseDeprecations'
|
||||
'verboseDeprecations',
|
||||
'extraItStackFrames',
|
||||
'extraDescribeStackFrames'
|
||||
];
|
||||
Object.freeze(standardBooleanKeys);
|
||||
Object.freeze(allKeys);
|
||||
@@ -32,6 +34,8 @@ describe('Configuration', function() {
|
||||
expect(subject.forbidDuplicateNames).toEqual(false);
|
||||
expect(subject.verboseDeprecations).toEqual(false);
|
||||
expect(subject.detectLateRejectionHandling).toEqual(false);
|
||||
expect(subject.extraItStackFrames).toEqual(0);
|
||||
expect(subject.extraDescribeStackFrames).toEqual(0);
|
||||
});
|
||||
|
||||
describe('copy()', function() {
|
||||
@@ -130,5 +134,25 @@ describe('Configuration', function() {
|
||||
subject.update({ seed: null });
|
||||
expect(subject.seed).toBeNull();
|
||||
});
|
||||
|
||||
it('sets extraItStackFrames when not undefined', function() {
|
||||
const subject = new jasmineUnderTest.Configuration();
|
||||
|
||||
subject.update({ extraItStackFrames: undefined });
|
||||
expect(subject.extraItStackFrames).toEqual(0);
|
||||
|
||||
subject.update({ extraItStackFrames: 100000 });
|
||||
expect(subject.extraItStackFrames).toEqual(100000);
|
||||
});
|
||||
|
||||
it('sets extraDescribeStackFrames when not undefined', function() {
|
||||
const subject = new jasmineUnderTest.Configuration();
|
||||
|
||||
subject.update({ extraDescribeStackFrames: undefined });
|
||||
expect(subject.extraDescribeStackFrames).toEqual(0);
|
||||
|
||||
subject.update({ extraDescribeStackFrames: 100000 });
|
||||
expect(subject.extraDescribeStackFrames).toEqual(100000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -95,7 +95,7 @@ describe('Env', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('accepts its own current configureation', function() {
|
||||
it('accepts its own current configuration', function() {
|
||||
env.configure(env.configuration());
|
||||
});
|
||||
|
||||
@@ -198,6 +198,29 @@ describe('Env', function() {
|
||||
expect(innerSuite.parentSuite).toBe(suite);
|
||||
expect(spec.getFullName()).toEqual('outer suite inner suite a spec');
|
||||
});
|
||||
|
||||
it('sets the caller filename correctly when extraDescribeStackFrames is not set', function() {
|
||||
// IIFE is used to match the stack depth when global describe() is called
|
||||
const suite = (function() {
|
||||
return env[methodName]('a suite', function() {
|
||||
env.it('a spec');
|
||||
});
|
||||
})();
|
||||
expect(suite.filename).toMatch(/EnvSpec\.js$/);
|
||||
});
|
||||
|
||||
it('sets the caller filename correctly when extraDescribeStackFrames is set', function() {
|
||||
env.configure({ extraDescribeStackFrames: 2 });
|
||||
// IIFE is used to match the stack depth when global describe() is called
|
||||
const suite = (function() {
|
||||
return specHelpers.callerFilenameShim(function() {
|
||||
return env[methodName]('a suite', function() {
|
||||
env.it('a spec');
|
||||
});
|
||||
});
|
||||
})();
|
||||
expect(suite.filename).toMatch(/EnvSpec\.js$/);
|
||||
});
|
||||
}
|
||||
|
||||
describe('#describe', function() {
|
||||
@@ -300,6 +323,25 @@ describe('Env', function() {
|
||||
.not.toEqual('');
|
||||
expect(spec.pend).toBeFalsy();
|
||||
});
|
||||
|
||||
it('sets the caller filename correctly when extraItStackFrames is not set', function() {
|
||||
// IIFE is used to match the stack depth when global it() is called
|
||||
const spec = (function() {
|
||||
return env[methodName]('a spec', function() {});
|
||||
})();
|
||||
expect(spec.filename).toMatch(/EnvSpec\.js$/);
|
||||
});
|
||||
|
||||
it('sets the caller filename correctly when extraItStackFrames is set', function() {
|
||||
env.configure({ extraItStackFrames: 2 });
|
||||
// IIFE is used to match the stack depth when global it() is called
|
||||
const spec = (function() {
|
||||
return specHelpers.callerFilenameShim(function() {
|
||||
return env[methodName]('a spec', function() {});
|
||||
});
|
||||
})();
|
||||
expect(spec.filename).toMatch(/EnvSpec\.js$/);
|
||||
});
|
||||
}
|
||||
|
||||
describe('#it', function() {
|
||||
|
||||
5
spec/helpers/callerFilenameShim.js
Normal file
5
spec/helpers/callerFilenameShim.js
Normal file
@@ -0,0 +1,5 @@
|
||||
(function() {
|
||||
specHelpers.callerFilenameShim = function(fn) {
|
||||
return fn();
|
||||
};
|
||||
})();
|
||||
@@ -23,6 +23,7 @@ module.exports = {
|
||||
'helpers/BrowserFlags.js',
|
||||
'helpers/domHelpers.js',
|
||||
'helpers/integrationMatchers.js',
|
||||
'helpers/callerFilenameShim.js',
|
||||
'helpers/defineJasmineUnderTest.js',
|
||||
'helpers/resetEnv.js'
|
||||
],
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"helpers/init.js",
|
||||
"helpers/domHelpers.js",
|
||||
"helpers/integrationMatchers.js",
|
||||
"helpers/callerFilenameShim.js",
|
||||
"helpers/overrideConsoleLogForCircleCi.js",
|
||||
"helpers/nodeDefineJasmineUnderTest.js",
|
||||
"helpers/resetEnv.js"
|
||||
|
||||
Reference in New Issue
Block a user