Skip to content
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

feat(adapter.jasmine): remove only last failed specs anti-feature #361

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions adapter/jasmine.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,11 @@ var indexOf = function(collection, item) {
*/
var TestacularReporter = function(tc) {

var failedIds = [];

this.reportRunnerStarting = function(runner) {
tc.info({total: runner.specs().length});
};

this.reportRunnerResults = function(runner) {
tc.store('jasmine.lastFailedIds', failedIds);
tc.complete({
coverage: window.__coverage__
});
Expand Down Expand Up @@ -84,8 +81,6 @@ var TestacularReporter = function(tc) {
result.log.push(formatFailedStep(steps[i]));
}
}

failedIds.push(result.id);
}

tc.result(result);
Expand All @@ -105,24 +100,6 @@ var createStartFn = function(tc, jasmineEnvPassedIn) {
// we pass jasmineEnv during testing
// in production we ask for it lazily, so that adapter can be loaded even before jasmine
var jasmineEnv = jasmineEnvPassedIn || window.jasmine.getEnv();
var currentSpecsCount = jasmineEnv.nextSpecId_;
var lastCount = tc.store('jasmine.lastCount');
var lastFailedIds = tc.store('jasmine.lastFailedIds');

tc.store('jasmine.lastCount', currentSpecsCount);
tc.store('jasmine.lastFailedIds', []);

// filter only last failed specs
if (lastCount === currentSpecsCount && // still same number of specs
lastFailedIds.length > 0 && // at least one fail last run
!jasmineEnv.exclusive_) { // no exclusive mode (iit, ddesc)

jasmineEnv.specFilter = function(spec) {
return indexOf(lastFailedIds, spec.id) !== -1;
};
}



jasmineEnv.addReporter(new TestacularReporter(tc));
jasmineEnv.execute();
Expand Down
109 changes: 0 additions & 109 deletions test/client/jasmine.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,6 @@ describe('jasmine adapter', function() {
});


it('should report failed ids', function() {
var specs = [ // id
spec, // 0
new jasmine.Spec(env, suite, 'should test'), // 1
new jasmine.Spec(env, suite, 'should test'), // 2
new jasmine.Spec(env, suite, 'should test') // 3
];

specs[1].fail(new Error('Some error'));
specs[2].fail(new Error('Another error'));

while(specs.length) {
reporter.reportSpecResults(specs.shift());
}
reporter.reportRunnerResults();

expect(testacular.store('jasmine.lastFailedIds')).toEqual([1, 2]);
});


it('should remove jasmine-specific frames from the exception stack traces', function() {
var error = new Error("Expected 'function' to be 'fxunction'");
error.stack = "Error: Expected 'function' to be 'fxunction'.\n" +
Expand Down Expand Up @@ -154,8 +134,6 @@ describe('jasmine adapter', function() {

beforeEach(function() {
tc = new Testacular(new MockSocket(), {});
tc.store('jasmine.lastFailedIds', [1, 3, 5]);
tc.store('jasmine.lastCount', 10);

spyOn(tc, 'info');
spyOn(tc, 'complete');
Expand All @@ -164,93 +142,6 @@ describe('jasmine adapter', function() {
jasmineEnv = new jasmine.Env();
start = createStartFn(tc, jasmineEnv);
});


it('should reset last results', function() {
start();
expect(tc.store('jasmine.lastCount')).toBe(0);
expect(tc.store('jasmine.lastFailedIds')).toEqual([]);
});


it('should store failed ids', function() {
jasmineEnv.describe('fake', function() {
jasmineEnv.it('should pass', function() {});
jasmineEnv.it('should fail', function() {throw new Error('FAIL');});
});

start();

waitsFor(function() {
return tc.store('jasmine.lastFailedIds').length === 1;
}, 'execution finish', 50);

runs(function() {
expect(tc.store('jasmine.lastFailedIds')).toEqual([1]);
});
});


describe('specFilter', function() {
var originalSpecFilter = 'ORIGINAL SPEC FILTER';

beforeEach(function() {
jasmineEnv.specFilter = originalSpecFilter;
});


it('should filter only last failed', function() {
tc.store('jasmine.lastFailedIds', [1, 3, 5]);
tc.store('jasmine.lastCount', 5);
jasmineEnv.nextSpecId_ = 5;

start();
expect(jasmineEnv.specFilter({id: 1})).toBe(true);
expect(jasmineEnv.specFilter({id: 2})).toBe(false);
expect(jasmineEnv.specFilter({id: 3})).toBe(true);
expect(jasmineEnv.specFilter({id: 4})).toBe(false);
expect(jasmineEnv.specFilter({id: 5})).toBe(true);
});


it('should not filter if first run', function() {
tc.store('jasmine.lastFailedIds', null);
tc.store('jasmine.lastCount', null);

start();
expect(jasmineEnv.specFilter).toBe(originalSpecFilter);
});


it('should not filter if number of specs changed', function() {
tc.store('jasmine.lastCount', 10);
jasmineEnv.nextSpecId_ = 5;

start();
expect(jasmineEnv.specFilter).toBe(originalSpecFilter);
});


it('should not filter if all specs passed last time', function() {
tc.store('jasmine.lastFailedIds', []);
tc.store('jasmine.lastCount', 5);
jasmineEnv.nextSpecId_ = 5;

start();
expect(jasmineEnv.specFilter).toBe(originalSpecFilter);
});


it('should not filter if exclusive mode', function() {
tc.store('jasmine.lastFailedIds', [1, 3, 5]);
tc.store('jasmine.lastCount', 5);
jasmineEnv.nextSpecId_ = 5;
jasmineEnv.exclusive_ = 1;

start();
expect(jasmineEnv.specFilter).toBe(originalSpecFilter);
});
});
});


Expand Down