Skip to content

Commit 8f0d866

Browse files
committed
Use deterministic, internal IDs
This helps a bit with experimentalRunAllSpecs: true, relates to #948.
1 parent b1174ea commit 8f0d866

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file.
88

99
- Replace [cucumber-json-formatter](https://github.com/cucumber/json-formatter) with native components, relates to [#795](https://github.com/badeball/cypress-cucumber-preprocessor/issues/795), [#827](https://github.com/badeball/cypress-cucumber-preprocessor/issues/827), [#870](https://github.com/badeball/cypress-cucumber-preprocessor/issues/870), [#966](https://github.com/badeball/cypress-cucumber-preprocessor/issues/966) and [#967](https://github.com/badeball/cypress-cucumber-preprocessor/issues/967).
1010

11+
- Use deterministic, internal IDs, fixes [#948](https://github.com/badeball/cypress-cucumber-preprocessor/issues/948) to some degree..
12+
1113
## v15.1.5
1214

1315
- Correctly escape injected values to glob patterns, fixes [#946](https://github.com/badeball/cypress-cucumber-preprocessor/issues/946).

features/issues/908.feature

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ Feature: hide internals from cypress environment
1212
"""
1313
const { Then } = require("@badeball/cypress-cucumber-preprocessor");
1414
const { INTERNAL_SPEC_PROPERTIES } = require("@badeball/cypress-cucumber-preprocessor/lib/constants");
15-
// From https://github.com/rfrench/chai-uuid/blob/master/index.js.
16-
const UUID_V4_EXPR = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
1715
Then("the visible internal state should be a mere reference", () => {
1816
const properties = Cypress.env(INTERNAL_SPEC_PROPERTIES);
19-
expect(properties).to.be.a("string");
20-
expect(properties).to.match(UUID_V4_EXPR);
17+
expect(properties).to.be.a("number");
2118
});
2219
"""
2320
When I run cypress

lib/create-tests.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,19 @@ export interface InternalSuiteProperties {
102102
isEventHandlersAttached?: boolean;
103103
}
104104

105-
const internalSpecProperties = new Map<string, InternalSpecProperties>();
105+
let specId = 0;
106+
107+
const internalSpecProperties = new Map<number, InternalSpecProperties>();
106108

107109
function createInternalSpecProperties(
108110
properties: InternalSpecProperties
109-
): string {
110-
const reference = uuid();
111-
internalSpecProperties.set(reference, properties);
112-
return reference;
111+
): number {
112+
internalSpecProperties.set(++specId, properties);
113+
return specId;
113114
}
114115

115116
export function retrieveInternalSpecProperties(): InternalSpecProperties {
116-
const reference = Cypress.env(INTERNAL_SPEC_PROPERTIES) as string;
117+
const reference = Cypress.env(INTERNAL_SPEC_PROPERTIES) as number;
117118

118119
return assertAndReturn(
119120
internalSpecProperties.get(reference),

0 commit comments

Comments
 (0)