Skip to content

Commit

Permalink
Additional changes to avoid config deprecation warnings (from jasmine…
Browse files Browse the repository at this point in the history
…-core).
  • Loading branch information
claudiosdc committed Nov 30, 2018
1 parent 86a4a1a commit 7405df3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
24 changes: 12 additions & 12 deletions lib/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ function Jasmine(options) {
}

Jasmine.prototype.randomizeTests = function(value) {
this.env.randomizeTests(value);
this.env.configure({random: value});
};

Jasmine.prototype.seed = function(value) {
this.env.seed(value);
this.env.configure({seed: value});
};

Jasmine.prototype.showColors = function(value) {
Expand Down Expand Up @@ -115,22 +115,22 @@ Jasmine.prototype.loadConfigFile = function(configFilePath) {
Jasmine.prototype.loadConfig = function(config) {
this.specDir = config.spec_dir || this.specDir;

var configOptions = {};
var configuration = {};

if (config.stopSpecOnExpectationFailure !== undefined) {
configOptions.oneFailurePerSpec = config.stopSpecOnExpectationFailure;
configuration.oneFailurePerSpec = config.stopSpecOnExpectationFailure;
}

if (config.stopOnSpecFailure !== undefined) {
configOptions.failFast = config.stopOnSpecFailure;
configuration.failFast = config.stopOnSpecFailure;
}

if (config.random !== undefined) {
configOptions.random = config.random;
configuration.random = config.random;
}

if (Object.keys(configOptions).length > 0) {
this.env.configure(configOptions);
if (Object.keys(configuration).length > 0) {
this.env.configure(configuration);
}

if(config.helpers) {
Expand Down Expand Up @@ -195,11 +195,11 @@ Jasmine.prototype.onComplete = function(onCompleteCallback) {
};

Jasmine.prototype.stopSpecOnExpectationFailure = function(value) {
this.env.throwOnExpectationFailure(value);
this.env.configure({oneFailurePerSpec: value});
};

Jasmine.prototype.stopOnSpecFailure = function(value) {
this.env.stopOnSpecFailure(value);
this.env.configure({failFast: value});
};

Jasmine.prototype.exitCodeCompletion = function(passed) {
Expand Down Expand Up @@ -243,9 +243,9 @@ Jasmine.prototype.execute = function(files, filterString) {
var specFilter = new ConsoleSpecFilter({
filterString: filterString
});
this.env.specFilter = function(spec) {
this.env.configure({specFilter: function(spec) {
return specFilter.matches(spec.getFullName());
};
}});
}

if (files && files.length > 0) {
Expand Down
11 changes: 4 additions & 7 deletions spec/jasmine_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ describe('Jasmine', function() {
addMatchers: jasmine.createSpy('addMatchers'),
provideFallbackReporter: jasmine.createSpy('provideFallbackReporter'),
execute: jasmine.createSpy('execute'),
throwOnExpectationFailure: jasmine.createSpy('throwOnExpectationFailure'),
stopOnSpecFailure: jasmine.createSpy('stopOnSpecFailure'),
randomizeTests: jasmine.createSpy('randomizeTests'),
configure: jasmine.createSpy('configure')
}),
Timer: jasmine.createSpy('Timer')
Expand Down Expand Up @@ -297,21 +294,21 @@ describe('Jasmine', function() {
describe('#stopSpecOnExpectationFailure', function() {
it('sets the throwOnExpectationFailure value on the jasmine-core env', function() {
this.testJasmine.stopSpecOnExpectationFailure('foobar');
expect(this.testJasmine.env.throwOnExpectationFailure).toHaveBeenCalledWith('foobar');
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({oneFailurePerSpec: 'foobar'});
});
});

describe('#stopOnSpecFailure', function() {
it('sets the stopOnSpecFailure value on the jasmine-core env', function() {
this.testJasmine.stopOnSpecFailure('blah');
expect(this.testJasmine.env.stopOnSpecFailure).toHaveBeenCalledWith('blah');
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({failFast: 'blah'});
});
});

describe('#randomizeTests', function() {
it('sets the randomizeTests value on the jasmine-core env', function() {
this.testJasmine.randomizeTests('foobar');
expect(this.testJasmine.env.randomizeTests).toHaveBeenCalledWith('foobar');
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({random: 'foobar'});
});
});

Expand Down Expand Up @@ -402,7 +399,7 @@ describe('Jasmine', function() {
this.testJasmine.loadConfigFile();

this.testJasmine.execute(['spec/fixtures/**/*spec.js'], 'interesting spec');
expect(this.testJasmine.env.specFilter).toEqual(jasmine.any(Function));
expect(this.testJasmine.env.configure).toHaveBeenCalledWith({specFilter: jasmine.any(Function)});
});

it('adds an exit code reporter', function() {
Expand Down

0 comments on commit 7405df3

Please sign in to comment.