mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +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.
|
Single e2e tests can be run with `yarn test:e2e:single test/e2e/tests/TEST_NAME.spec.js` along with the options below.
|
||||||
|
|
||||||
```console
|
```console
|
||||||
--browser Set the browser used; either 'chrome' or 'firefox'.
|
--browser Set the browser used; either 'chrome' or 'firefox'.
|
||||||
[string] [choices: "chrome", "firefox"]
|
[string] [choices: "chrome", "firefox"]
|
||||||
--debug Run tests in debug mode, logging each driver interaction
|
--debug Run tests in debug mode, logging each driver interaction
|
||||||
[boolean] [default: false]
|
[boolean] [default: false]
|
||||||
--retries Set how many times the test should be retried upon failure.
|
--retries Set how many times the test should be retried upon failure.
|
||||||
[number] [default: 0]
|
[number] [default: 0]
|
||||||
--leave-running Leaves the browser running after a test fails, along with
|
--leave-running Leaves the browser running after a test fails, along with
|
||||||
anything else that the test used (ganache, the test dapp,
|
anything else that the test used (ganache, the test dapp,
|
||||||
etc.) [boolean] [default: false]
|
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:
|
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:
|
description:
|
||||||
'Set how many times the test should be retried upon failure.',
|
'Set how many times the test should be retried upon failure.',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
|
})
|
||||||
|
.option('update-snapshot', {
|
||||||
|
alias: 'u',
|
||||||
|
default: false,
|
||||||
|
description: 'Update E2E snapshots',
|
||||||
|
type: 'boolean',
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.strict()
|
.strict()
|
||||||
.help('help');
|
.help('help');
|
||||||
|
|
||||||
const { browser, debug, retries, snaps, mv3, rpc, buildType } = argv;
|
const {
|
||||||
|
browser,
|
||||||
|
debug,
|
||||||
|
retries,
|
||||||
|
snaps,
|
||||||
|
mv3,
|
||||||
|
rpc,
|
||||||
|
buildType,
|
||||||
|
updateSnapshot,
|
||||||
|
} = argv;
|
||||||
|
|
||||||
let testPaths;
|
let testPaths;
|
||||||
|
|
||||||
@ -130,6 +145,9 @@ async function main() {
|
|||||||
if (debug) {
|
if (debug) {
|
||||||
args.push('--debug');
|
args.push('--debug');
|
||||||
}
|
}
|
||||||
|
if (updateSnapshot) {
|
||||||
|
args.push('--update-snapshot');
|
||||||
|
}
|
||||||
|
|
||||||
// For running E2Es in parallel in CI
|
// For running E2Es in parallel in CI
|
||||||
const currentChunkIndex = process.env.CIRCLE_NODE_INDEX ?? 0;
|
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.)',
|
'Leaves the browser running after a test fails, along with anything else that the test used (ganache, the test dapp, etc.)',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
})
|
})
|
||||||
|
.option('update-snapshot', {
|
||||||
|
alias: 'u',
|
||||||
|
default: false,
|
||||||
|
description: 'Update E2E snapshots',
|
||||||
|
type: 'boolean',
|
||||||
|
})
|
||||||
.positional('e2e-test-path', {
|
.positional('e2e-test-path', {
|
||||||
describe: 'The path for the E2E test to run.',
|
describe: 'The path for the E2E test to run.',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
@ -58,6 +64,7 @@ async function main() {
|
|||||||
retries,
|
retries,
|
||||||
retryUntilFailure,
|
retryUntilFailure,
|
||||||
leaveRunning,
|
leaveRunning,
|
||||||
|
updateSnapshot,
|
||||||
} = argv;
|
} = argv;
|
||||||
|
|
||||||
if (!browser) {
|
if (!browser) {
|
||||||
@ -103,6 +110,10 @@ async function main() {
|
|||||||
exit = '--no-exit';
|
exit = '--no-exit';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updateSnapshot) {
|
||||||
|
process.env.UPDATE_SNAPSHOTS = 'true';
|
||||||
|
}
|
||||||
|
|
||||||
const configFile = path.join(__dirname, '.mocharc.js');
|
const configFile = path.join(__dirname, '.mocharc.js');
|
||||||
const extraArgs = process.env.E2E_ARGS?.split(' ') || [];
|
const extraArgs = process.env.E2E_ARGS?.split(' ') || [];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user