Skip to content
Open
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
5 changes: 4 additions & 1 deletion bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,10 @@ exports.setNodeVersion = (bsConfig, args) => {
// command line args takes precedence over config
exports.setUserSpecs = (bsConfig, args) => {
if(o11yHelpers.isBrowserstackInfra() && o11yHelpers.isTestObservabilitySession() && o11yHelpers.shouldReRunObservabilityTests()) {
bsConfig.run_settings.specs = process.env.BROWSERSTACK_RERUN_TESTS;
// BROWSERSTACK_RERUN_TESTS arrives comma+space separated (e.g. "a.ts, b.ts"); normalise
// like the other spec sources below, else sanitizeSpecsPattern builds "{a.ts, b.ts}" whose
// space-prefixed brace alternatives never match and the failed-spec filter collapses.
bsConfig.run_settings.specs = this.fixCommaSeparatedString(process.env.BROWSERSTACK_RERUN_TESTS);
return;
}

Expand Down
5 changes: 4 additions & 1 deletion bin/testObservability/helper/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,10 @@ const getReRunSpecs = (rawArgs) => {
}
}
if(startIdx != -1) rawArgs.splice(startIdx, numEle + 1);
finalArgs = [...rawArgs, '--spec', process.env.BROWSERSTACK_RERUN_TESTS];
// Normalise the comma+space separated rerun list ("a.ts, b.ts") to comma-only before
// handing it to cypress --spec; a leading space makes cypress miss every spec but the first.
const reRunSpecs = process.env.BROWSERSTACK_RERUN_TESTS.split(",").map(spec => spec.trim()).filter(Boolean).join(",");
finalArgs = [...rawArgs, '--spec', reRunSpecs];
}
return finalArgs.filter(item => item !== '--disable-test-observability' && item !== '--disable-browserstack-automation');
}
Expand Down
27 changes: 27 additions & 0 deletions test/unit/bin/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,33 @@ describe('utils', () => {
expect(bsConfig.run_settings.specs).to.be.eq('spec1,spec2');
});

context('when re-running observability failed tests (BROWSERSTACK_RERUN_TESTS)', () => {
let rerunStubs = [];
beforeEach(() => {
rerunStubs.push(sinon.stub(o11yHelpers, 'isBrowserstackInfra').returns(true));
rerunStubs.push(sinon.stub(o11yHelpers, 'isTestObservabilitySession').returns(true));
rerunStubs.push(sinon.stub(o11yHelpers, 'shouldReRunObservabilityTests').returns(true));
});
afterEach(() => {
rerunStubs.forEach((s) => s.restore());
rerunStubs = [];
delete process.env.BROWSERSTACK_RERUN_TESTS;
});

it('normalises the comma+space separated rerun spec list to comma-only (SDK-7124)', () => {
process.env.BROWSERSTACK_RERUN_TESTS =
'FO-E2E-05.ts, FO-E2E-02.ts, FO-E2E-06.ts, FO-E2E-07.ts, FO-E2E-03.ts';
let bsConfig = { run_settings: { specs: ['some/other/spec.js'] } };

utils.setUserSpecs(bsConfig, { specs: null });

expect(bsConfig.run_settings.specs).to.be.eq(
'FO-E2E-05.ts,FO-E2E-02.ts,FO-E2E-06.ts,FO-E2E-07.ts,FO-E2E-03.ts'
);
expect(bsConfig.run_settings.specs).to.not.contain(' ');
});
});

it('does not set the specs list if no specs key specified', () => {
let bsConfig = {
run_settings: {},
Expand Down
Loading