mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Add e2e debugging logs (#16937)
A `debug` flag has been added to our e2e test runner scripts, enabling e2e debug logs. When this flag is enabled, all driver interactions will be logged to the console. This is extremely useful when debugging e2e tests, because it lets you known how far the test had progressed before failing. This flag should work with all existing e2e test scripts, including both `test:e2e:single` and all of the test commands that run entire test suites. The README has been updated to reference this flag in the section regarding how to run a single e2e test. To ensure this wasn't totally missed for the other scripts, I added a line suggesting that users use `--help` to see all supported options.
This commit is contained in:
parent
69e5d6da4a
commit
5857b85225
21
README.md
21
README.md
@ -68,21 +68,26 @@ Our e2e test suite can be run on either Firefox or Chrome.
|
|||||||
* Firefox e2e tests can be run with `yarn test:e2e:firefox`.
|
* Firefox e2e tests can be run with `yarn test:e2e:firefox`.
|
||||||
* Chrome e2e tests can be run with `yarn test:e2e:chrome`. The `chromedriver` package major version must match the major version of your local Chrome installation. If they don't match, update whichever is behind before running Chrome e2e tests.
|
* Chrome e2e tests can be run with `yarn test:e2e:chrome`. The `chromedriver` package major version must match the major version of your local Chrome installation. If they don't match, update whichever is behind before running Chrome e2e tests.
|
||||||
|
|
||||||
|
These test scripts all support additional options, which might be helpful for debugging. Run the script with the flag `--help` to see all options.
|
||||||
|
|
||||||
#### Running a single e2e test
|
#### Running a single e2e test
|
||||||
|
|
||||||
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"]
|
||||||
--leave-running Leaves the browser running after a test fails, along with anything else
|
--debug Run tests in debug mode, logging each driver interaction
|
||||||
that the test used (ganache, the test dapp, etc.).
|
[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. Default is 0.
|
[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]
|
||||||
```
|
```
|
||||||
|
|
||||||
An example for running `account-details` testcase with chrome and leaving the browser open would be:
|
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:
|
||||||
`yarn test:e2e:single test/e2e/tests/account-details.spec.js --browser=chrome --leave-running`
|
`yarn test:e2e:single test/e2e/tests/account-details.spec.js --browser=chrome --debug --leave-running`
|
||||||
|
|
||||||
### Changing dependencies
|
### Changing dependencies
|
||||||
|
|
||||||
|
@ -120,8 +120,28 @@ async function withFixtures(options, testSuite) {
|
|||||||
await driver.checkBrowserForExceptions();
|
await driver.checkBrowserForExceptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let driverProxy;
|
||||||
|
if (process.env.E2E_DEBUG === 'true') {
|
||||||
|
driverProxy = new Proxy(driver, {
|
||||||
|
get(target, prop, receiver) {
|
||||||
|
const originalProperty = target[prop];
|
||||||
|
if (typeof originalProperty === 'function') {
|
||||||
|
return (...args) => {
|
||||||
|
console.log(
|
||||||
|
`[driver] Called '${prop}' with arguments ${JSON.stringify(
|
||||||
|
args,
|
||||||
|
)}`,
|
||||||
|
);
|
||||||
|
return originalProperty.bind(target)(...args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return Reflect.get(target, prop, receiver);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await testSuite({
|
await testSuite({
|
||||||
driver,
|
driver: driverProxy ?? driver,
|
||||||
mockServer,
|
mockServer,
|
||||||
contractRegistry,
|
contractRegistry,
|
||||||
});
|
});
|
||||||
|
@ -36,6 +36,12 @@ async function main() {
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
choices: ['chrome', 'firefox'],
|
choices: ['chrome', 'firefox'],
|
||||||
})
|
})
|
||||||
|
.option('debug', {
|
||||||
|
default: process.env.E2E_DEBUG === 'true',
|
||||||
|
description:
|
||||||
|
'Run tests in debug mode, logging each driver interaction',
|
||||||
|
type: 'boolean',
|
||||||
|
})
|
||||||
.option('snaps', {
|
.option('snaps', {
|
||||||
description: `run snaps e2e tests`,
|
description: `run snaps e2e tests`,
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
@ -53,7 +59,7 @@ async function main() {
|
|||||||
.strict()
|
.strict()
|
||||||
.help('help');
|
.help('help');
|
||||||
|
|
||||||
const { browser, retries, snaps, mv3 } = argv;
|
const { browser, debug, retries, snaps, mv3 } = argv;
|
||||||
|
|
||||||
let testPaths;
|
let testPaths;
|
||||||
|
|
||||||
@ -84,6 +90,9 @@ async function main() {
|
|||||||
if (retries) {
|
if (retries) {
|
||||||
args.push('--retries', retries);
|
args.push('--retries', retries);
|
||||||
}
|
}
|
||||||
|
if (debug) {
|
||||||
|
args.push('--debug');
|
||||||
|
}
|
||||||
|
|
||||||
// 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;
|
||||||
|
@ -18,6 +18,12 @@ async function main() {
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
choices: ['chrome', 'firefox'],
|
choices: ['chrome', 'firefox'],
|
||||||
})
|
})
|
||||||
|
.option('debug', {
|
||||||
|
default: process.env.E2E_DEBUG === 'true',
|
||||||
|
description:
|
||||||
|
'Run tests in debug mode, logging each driver interaction',
|
||||||
|
type: 'boolean',
|
||||||
|
})
|
||||||
.option('retries', {
|
.option('retries', {
|
||||||
default: 0,
|
default: 0,
|
||||||
description:
|
description:
|
||||||
@ -39,7 +45,7 @@ async function main() {
|
|||||||
.strict()
|
.strict()
|
||||||
.help('help');
|
.help('help');
|
||||||
|
|
||||||
const { browser, e2eTestPath, retries, leaveRunning } = argv;
|
const { browser, debug, e2eTestPath, retries, leaveRunning } = argv;
|
||||||
|
|
||||||
if (!browser) {
|
if (!browser) {
|
||||||
exitWithError(
|
exitWithError(
|
||||||
@ -69,6 +75,10 @@ async function main() {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
process.env.E2E_DEBUG = 'true';
|
||||||
|
}
|
||||||
|
|
||||||
let testTimeoutInMilliseconds = 60 * 1000;
|
let testTimeoutInMilliseconds = 60 * 1000;
|
||||||
let exit = '--exit';
|
let exit = '--exit';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user