mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-21 17:37:01 +01:00
Add flag to update E2E snapshots (#20514)
The E2E test scripts now have a flag for updating E2E test snapshots. The flag has been documented as well. This makes it easier to update snapshots and raises visbility of this feature.
This commit is contained in:
parent
861c30de29
commit
6c50587878
20
README.md
20
README.md
@ -88,15 +88,17 @@ These test scripts all support additional options, which might be helpful for de
|
||||
Single e2e tests can be run with `yarn test:e2e:single test/e2e/tests/TEST_NAME.spec.js` along with the options below.
|
||||
|
||||
```console
|
||||
--browser Set the browser used; either 'chrome' or 'firefox'.
|
||||
[string] [choices: "chrome", "firefox"]
|
||||
--debug Run tests in debug mode, logging each driver interaction
|
||||
[boolean] [default: false]
|
||||
--retries Set how many times the test should be retried upon failure.
|
||||
[number] [default: 0]
|
||||
--leave-running Leaves the browser running after a test fails, along with
|
||||
anything else that the test used (ganache, the test dapp,
|
||||
etc.) [boolean] [default: false]
|
||||
--browser Set the browser used; either 'chrome' or 'firefox'.
|
||||
[string] [choices: "chrome", "firefox"]
|
||||
--debug Run tests in debug mode, logging each driver interaction
|
||||
[boolean] [default: false]
|
||||
--retries Set how many times the test should be retried upon failure.
|
||||
[number] [default: 0]
|
||||
--leave-running Leaves the browser running after a test fails, along with
|
||||
anything else that the test used (ganache, the test dapp,
|
||||
etc.) [boolean] [default: false]
|
||||
--update-snapshot Update E2E test snapshots
|
||||
[alias: -u] [boolean] [default: false]
|
||||
```
|
||||
|
||||
For example, to run the `account-details` tests using Chrome, with debug logging and with the browser set to remain open upon failure, you would use:
|
||||
|
@ -74,12 +74,27 @@ async function main() {
|
||||
description:
|
||||
'Set how many times the test should be retried upon failure.',
|
||||
type: 'number',
|
||||
})
|
||||
.option('update-snapshot', {
|
||||
alias: 'u',
|
||||
default: false,
|
||||
description: 'Update E2E snapshots',
|
||||
type: 'boolean',
|
||||
}),
|
||||
)
|
||||
.strict()
|
||||
.help('help');
|
||||
|
||||
const { browser, debug, retries, snaps, mv3, rpc, buildType } = argv;
|
||||
const {
|
||||
browser,
|
||||
debug,
|
||||
retries,
|
||||
snaps,
|
||||
mv3,
|
||||
rpc,
|
||||
buildType,
|
||||
updateSnapshot,
|
||||
} = argv;
|
||||
|
||||
let testPaths;
|
||||
|
||||
@ -130,6 +145,9 @@ async function main() {
|
||||
if (debug) {
|
||||
args.push('--debug');
|
||||
}
|
||||
if (updateSnapshot) {
|
||||
args.push('--update-snapshot');
|
||||
}
|
||||
|
||||
// For running E2Es in parallel in CI
|
||||
const currentChunkIndex = process.env.CIRCLE_NODE_INDEX ?? 0;
|
||||
|
@ -42,6 +42,12 @@ async function main() {
|
||||
'Leaves the browser running after a test fails, along with anything else that the test used (ganache, the test dapp, etc.)',
|
||||
type: 'boolean',
|
||||
})
|
||||
.option('update-snapshot', {
|
||||
alias: 'u',
|
||||
default: false,
|
||||
description: 'Update E2E snapshots',
|
||||
type: 'boolean',
|
||||
})
|
||||
.positional('e2e-test-path', {
|
||||
describe: 'The path for the E2E test to run.',
|
||||
type: 'string',
|
||||
@ -58,6 +64,7 @@ async function main() {
|
||||
retries,
|
||||
retryUntilFailure,
|
||||
leaveRunning,
|
||||
updateSnapshot,
|
||||
} = argv;
|
||||
|
||||
if (!browser) {
|
||||
@ -103,6 +110,10 @@ async function main() {
|
||||
exit = '--no-exit';
|
||||
}
|
||||
|
||||
if (updateSnapshot) {
|
||||
process.env.UPDATE_SNAPSHOTS = 'true';
|
||||
}
|
||||
|
||||
const configFile = path.join(__dirname, '.mocharc.js');
|
||||
const extraArgs = process.env.E2E_ARGS?.split(' ') || [];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user