Skip to content

Commit

Permalink
dev(chore): log test names and suites (#21570)
Browse files Browse the repository at this point in the history
## **Description**
Before #21441 the test reporter would output the test path it was
executing which made figuring out where tests were failing at fairly
easy. The updates in #21441 make tests run faster but it doesn't help
when trying to ascertain where failures occur. To make it slightly
easier this PR adds some reporting to the run-all script and the
withFixtures and verboseReportOnFailure functions to explicitly call out
where breakdowns happen.

This PR also changes from using `this.test.title` to
`this.test.fullTitle()` which includes the name spacing of Describe
Blocks for easier access.

## **Related issues**


## **Manual testing steps**

1. View CircleCI output on develop for any of the E2E tests.
2. Observe that the test steps are written out verbosely, but no
information about what file or test is being ran.
3. Do the same on this branch's CircleCI output and see the the test
files and names are logged.
4. Repeat steps locally on develop and this branch to see local terminal
console outputs file paths and test names.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**
<img width="1271" alt="Screenshot 2023-10-26 at 1 48 27 PM"
src="https://github.com/MetaMask/metamask-extension/assets/4448075/9dae6c6c-9c6b-4fc6-8852-c02ae7662c65">

### **After**
<img width="1249" alt="Screenshot 2023-10-26 at 2 15 21 PM"
src="https://github.com/MetaMask/metamask-extension/assets/4448075/fa6058f9-31b5-4dc7-b0fc-d9a76ca92cb8">
<img width="1197" alt="Screenshot 2023-10-26 at 2 15 41 PM"
src="https://github.com/MetaMask/metamask-extension/assets/4448075/c5be627a-34fe-4e70-af1a-b478b0d06b4a">

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've clearly explained what problem this PR is solving and how it
is solved.
- [ ] I've linked related issues
- [x] I've included manual testing steps
- [x] I've included screenshots/recordings if applicable
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
- [x] I’ve properly set the pull request status:
  - [ ] In case it's not yet "ready for review", I've set it to "draft".
- [x] In case it's "ready for review", I've changed it from "draft" to
"non-draft".

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

---------

Co-authored-by: Howard Braham <[email protected]>
  • Loading branch information
brad-decker and HowardBraham authored Oct 31, 2023
1 parent 6bffbab commit c3f6e17
Show file tree
Hide file tree
Showing 117 changed files with 284 additions and 267 deletions.
6 changes: 3 additions & 3 deletions test/e2e/accounts/test-create-snap-account.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Create Snap Account', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions: defaultGanacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('Create Snap Account', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions: defaultGanacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down Expand Up @@ -196,7 +196,7 @@ describe('Create Snap Account', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions: defaultGanacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/accounts/test-remove-accounts-snap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Remove Account Snap', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions: defaultGanacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/accounts/test-snap-accounts.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Test Snap Account', function () {

it('can create a new Snap account', async function () {
await withFixtures(
accountSnapFixtures(this.test.title),
accountSnapFixtures(this.test.fullTitle()),
async ({ driver }) => {
await installSnapSimpleKeyring(driver, false);

Expand All @@ -66,7 +66,7 @@ describe('Test Snap Account', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions: defaultGanacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await installSnapSimpleKeyring(driver, false);
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('Test Snap Account', function () {

it('can import a private key and transfer 1 ETH (sync flow)', async function () {
await withFixtures(
accountSnapFixtures(this.test.title),
accountSnapFixtures(this.test.fullTitle()),
async ({ driver }) => {
await importPrivateKeyAndTransfer1ETH(driver, 'sync');
},
Expand All @@ -144,7 +144,7 @@ describe('Test Snap Account', function () {

it('can import a private key and transfer 1 ETH (async flow approve)', async function () {
await withFixtures(
accountSnapFixtures(this.test.title),
accountSnapFixtures(this.test.fullTitle()),
async ({ driver }) => {
await importPrivateKeyAndTransfer1ETH(driver, 'approve');
},
Expand All @@ -153,7 +153,7 @@ describe('Test Snap Account', function () {

it('can import a private key and transfer 1 ETH (async flow reject)', async function () {
await withFixtures(
accountSnapFixtures(this.test.title),
accountSnapFixtures(this.test.fullTitle()),
async ({ driver }) => {
await importPrivateKeyAndTransfer1ETH(driver, 'reject');
},
Expand Down Expand Up @@ -188,7 +188,7 @@ describe('Test Snap Account', function () {

it(title, async function () {
await withFixtures(
accountSnapFixtures(this.test.title),
accountSnapFixtures(this.test.fullTitle()),
async ({ driver }) => {
const isAsyncFlow = flowType !== 'sync';

Expand All @@ -211,7 +211,7 @@ describe('Test Snap Account', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
const flowType = 'approve';
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/flask/petnames.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe('Petnames', function () {
.withNoNames()
.build(),
ganacheOptions,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await login(driver);
Expand Down Expand Up @@ -193,7 +193,7 @@ describe('Petnames', function () {
.withNoNames()
.build(),
ganacheOptions,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await login(driver);
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('Petnames', function () {
.withNoNames()
.build(),
ganacheOptions,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await login(driver);
Expand Down
8 changes: 7 additions & 1 deletion test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ async function withFixtures(options, testSuite) {
});
}

console.log(`\nExecuting test suite: ${title}\n`);

await testSuite({
driver: driverProxy ?? driver,
contractRegistry,
Expand All @@ -157,6 +159,10 @@ async function withFixtures(options, testSuite) {
mockedEndpoint,
});

// At this point the suite has executed successfully, so we can log out a
// success message.
console.log(`\nSuccess on test suite: '${title}'\n`);

// Evaluate whether any new hosts received network requests during E2E test
// suite execution. If so, fail the test unless the
// --update-privacy-snapshot was specified. In that case, update the
Expand Down Expand Up @@ -199,7 +205,7 @@ async function withFixtures(options, testSuite) {
failed = true;
if (webDriver) {
try {
await driver.verboseReportOnFailure(title);
await driver.verboseReportOnFailure(title, error);
} catch (verboseReportError) {
console.error(verboseReportError);
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/json-rpc/eth_accounts.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('eth_accounts', function () {
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/json-rpc/eth_call.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('eth_call', function () {
.build(),
ganacheOptions,
smartContract,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver, _, contractRegistry }) => {
const contract = contractRegistry.getContractAddress(smartContract);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/json-rpc/eth_chainId.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('eth_chainId', function () {
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/json-rpc/eth_estimateGas.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('eth_estimateGas', function () {
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/json-rpc/eth_gasPrice.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('eth_gasPrice', function () {
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/json-rpc/eth_newBlockFilter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('eth_newBlockFilter', function () {
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/json-rpc/eth_sendTransaction.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('eth_sendTransaction', function () {
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('eth_sendTransaction', function () {
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/json-rpc/switchEthereumChain.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Switch Ethereum Chain for two dapps', function () {
...defaultGanacheOptions,
concurrent: { port: 8546, chainId: 1338 },
},
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('Switch Ethereum Chain for two dapps', function () {
...defaultGanacheOptions,
concurrent: { port: 8546, chainId: 1338 },
},
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('Switch Ethereum Chain for two dapps', function () {
...defaultGanacheOptions,
concurrent: { port: 8546, chainId: 1338 },
},
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down Expand Up @@ -244,7 +244,7 @@ describe('Switch Ethereum Chain for two dapps', function () {
...defaultGanacheOptions,
concurrent: { port: 8546, chainId: 1338 },
},
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/provider/eip-6963.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('EIP-6963 Provider', function () {
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
1 change: 1 addition & 0 deletions test/e2e/run-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ async function main() {
for (let testPath of myTestList) {
if (testPath !== '') {
testPath = testPath.replace('\n', ''); // sometimes there's a newline at the end of the testPath
console.log(`\nExecuting testPath: ${testPath}\n`);
await runInShell('node', [...args, testPath]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/snaps/test-snap-bip-32.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Test Snap bip-32', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/snaps/test-snap-bip-44.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Test Snap bip-44', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/snaps/test-snap-cronjob.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Test Snap Cronjob', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/snaps/test-snap-dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Test Snap Dialog', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/snaps/test-snap-ethprovider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Test Snap ethereum_provider', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/snaps/test-snap-get-locale.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Test Snap Get Locale', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/snaps/test-snap-getentropy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Test Snap getEntropy', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/snaps/test-snap-installed.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Test Snap Installed', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/snaps/test-snap-lifecycle.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Test Snap Lifecycle Hooks', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/snaps/test-snap-management.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Test Snap Management', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/snaps/test-snap-managestate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Test Snap manageState', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/snaps/test-snap-networkaccess.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Test Snap networkAccess', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/snaps/test-snap-notification.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Test Snap Notification', function () {
fixtures: new FixtureBuilder().build(),
ganacheOptions,
failOnConsoleError: false,
title: this.test.title,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
Expand Down
Loading

0 comments on commit c3f6e17

Please sign in to comment.