You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recording/Playback mode can be set globally or on a spec-by-spec basis (on a test-by-test basis? IE. A Spec having multiple tests but only some in 'record mode? Not tried yet :-) ).
When a test is executing, sometimes it - or its helper code - needs to know when mode the code is executing in. Ideally, a global property should be exposed that can be used anywhere in the test suite code.
IE.
if (cypressReplay.mode === ReplayMode.Recording) then {
// we are recording
} else {
/ we are not recording
}
A use case for is is in tests we currently have that require manual data entry in 'Recording' mode, but not (uses canned data) in Playback mode. The helper code that does the data entry needs to know what mode we are running in.
The text was updated successfully, but these errors were encountered:
Good shout - dunno... Not sure just a return value would help as that would mean the caller would be responsible for passing to any interested 'helper' code or making it available globally for 'helper' code to look up.
I'm gonna play with Cypress hooks to see if that can be leveraged to allow mode setting per-test (A spec may have a few tests and only one may need re-recording - so test-level mode setting quite important).
As the workaround, I just wrapped it and watched what mode was being set (We never do a global record and so setting the mode is only at the test level):-
import enableCypressReplay, { ReplayMode as Mode } from 'cypress-replay';
export class Replay {
private static isCurrectlyRecording: Mode | undefined = undefined;
public static isRecording(): boolean {
return (Replay.isCurrectlyRecording === Mode.Recording);
}
public static setRecordMode(mode: Mode) {
enableCypressReplay(mode);
Replay.isCurrectlyRecording = mode;
}
}
export namespace Replay {
export const ReplayMode = { ...Mode };
export type ReplayMode = typeof ReplayMode;
}
Recording/Playback mode can be set globally or on a spec-by-spec basis (on a test-by-test basis? IE. A Spec having multiple tests but only some in 'record mode? Not tried yet :-) ).
When a test is executing, sometimes it - or its helper code - needs to know when mode the code is executing in. Ideally, a global property should be exposed that can be used anywhere in the test suite code.
IE.
A use case for is is in tests we currently have that require manual data entry in 'Recording' mode, but not (uses canned data) in Playback mode. The helper code that does the data entry needs to know what mode we are running in.
The text was updated successfully, but these errors were encountered: