Skip to content

Commit

Permalink
Merge branch 'develop' into 17191/onboarding-unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tmashuang authored Feb 6, 2023
2 parents 68dfe0f + 080d72a commit 2c79659
Show file tree
Hide file tree
Showing 25 changed files with 379 additions and 70 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Run unit tests and the linter with `yarn test`. To run just unit tests, run `yar

You can run the linter by itself with `yarn lint`, and you can automatically fix some lint problems with `yarn lint:fix`. You can also run these two commands just on your local changes to save time with `yarn lint:changed` and `yarn lint:changed:fix` respectively.

For Jest debugging guide using Node.js, see [docs/tests/jest.md](docs/tests/jest.md).

### Running E2E Tests

Our e2e test suite can be run on either Firefox or Chrome.
Expand Down
4 changes: 4 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions docs/tests/jest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Getting Started

## Running a Jest test

```bash
> yarn jest <path>
```

## Debugging

### Debugging Jest in VS Code

1. Open **VS Code**
2. Open the “Run and Debug” panel (⇧⌘D)
3. Click the “JavaScript Debug Terminal” button to open the Terminal
4. Run Jest using Node

```bash
> yarn jest --watch <path>
```

Additional methods and information to debug in VS Code can be found [here](https://jestjs.io/docs/troubleshooting#debugging-in-vs-code)

### Debugging Jest on Chrome DevTools

1. Run Jest using Node with the V8 Inspector

```bash
> node --inspect ./node_modules/.bin/jest --watch -i <path>
or
> node --inspect ./node_modules/.bin/jest <path>
```

**Options:**

```jsx
node:
--inspect=[host:]port
Activate inspector on host:port. Default is 127.0.0.1:9229.
V8 Inspector integration allows attaching Chrome DevTools and IDEs
to Node.js instances for debugging and profiling. It uses the
Chrome DevTools Protocol.
jest:
--watch Watch files for changes and rerun tests
related to changed files. If you want to
re-run all tests when a file has changed,
use the `--watchAll` option. [boolean]
-i, --runInBand Run all tests serially in the current
process (rather than creating a worker pool
of child processes that run tests). This is
sometimes useful for debugging, but such use
cases are pretty rare. [boolean]
```


1. Open Chrome DevTools for Node
1. Open a **Chromium** browser
2. Go to [chrome://inspect/#devices](chrome://inspect/#devices)
3. Click “Open dedicated DevTools for Node” link
43 changes: 40 additions & 3 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -703,15 +703,16 @@
"setTimeout": true
},
"packages": {
"@ethersproject/abi": true,
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/assets-controllers>@metamask/abi-utils": true,
"@metamask/assets-controllers>@metamask/controller-utils": true,
"@metamask/assets-controllers>abort-controller": true,
"@metamask/assets-controllers>multiformats": true,
"@metamask/base-controller": true,
"@metamask/contract-metadata": true,
"@metamask/controller-utils": true,
"@metamask/metamask-eth-abis": true,
"@metamask/utils": true,
"browserify>events": true,
"eth-json-rpc-filters>async-mutex": true,
"eth-query": true,
Expand All @@ -721,6 +722,27 @@
"uuid": true
}
},
"@metamask/assets-controllers>@metamask/abi-utils": {
"packages": {
"@metamask/utils": true,
"@metamask/utils>superstruct": true
}
},
"@metamask/assets-controllers>@metamask/controller-utils": {
"globals": {
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>isomorphic-fetch": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true
}
},
"@metamask/assets-controllers>abort-controller": {
"globals": {
"AbortController": true
Expand Down Expand Up @@ -1204,12 +1226,27 @@
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/controller-utils>isomorphic-fetch": true,
"@metamask/phishing-controller>@metamask/controller-utils": true,
"@metamask/phishing-controller>eth-phishing-detect": true,
"punycode": true
}
},
"@metamask/phishing-controller>@metamask/controller-utils": {
"globals": {
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>isomorphic-fetch": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true
}
},
"@metamask/phishing-controller>eth-phishing-detect": {
"packages": {
"eslint>optionator>fast-levenshtein": true
Expand Down
43 changes: 40 additions & 3 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -703,15 +703,16 @@
"setTimeout": true
},
"packages": {
"@ethersproject/abi": true,
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/assets-controllers>@metamask/abi-utils": true,
"@metamask/assets-controllers>@metamask/controller-utils": true,
"@metamask/assets-controllers>abort-controller": true,
"@metamask/assets-controllers>multiformats": true,
"@metamask/base-controller": true,
"@metamask/contract-metadata": true,
"@metamask/controller-utils": true,
"@metamask/metamask-eth-abis": true,
"@metamask/utils": true,
"browserify>events": true,
"eth-json-rpc-filters>async-mutex": true,
"eth-query": true,
Expand All @@ -721,6 +722,27 @@
"uuid": true
}
},
"@metamask/assets-controllers>@metamask/abi-utils": {
"packages": {
"@metamask/utils": true,
"@metamask/utils>superstruct": true
}
},
"@metamask/assets-controllers>@metamask/controller-utils": {
"globals": {
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>isomorphic-fetch": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true
}
},
"@metamask/assets-controllers>abort-controller": {
"globals": {
"AbortController": true
Expand Down Expand Up @@ -1216,12 +1238,27 @@
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/controller-utils>isomorphic-fetch": true,
"@metamask/phishing-controller>@metamask/controller-utils": true,
"@metamask/phishing-controller>eth-phishing-detect": true,
"punycode": true
}
},
"@metamask/phishing-controller>@metamask/controller-utils": {
"globals": {
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>isomorphic-fetch": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true
}
},
"@metamask/phishing-controller>eth-phishing-detect": {
"packages": {
"eslint>optionator>fast-levenshtein": true
Expand Down
43 changes: 40 additions & 3 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -703,15 +703,16 @@
"setTimeout": true
},
"packages": {
"@ethersproject/abi": true,
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/assets-controllers>@metamask/abi-utils": true,
"@metamask/assets-controllers>@metamask/controller-utils": true,
"@metamask/assets-controllers>abort-controller": true,
"@metamask/assets-controllers>multiformats": true,
"@metamask/base-controller": true,
"@metamask/contract-metadata": true,
"@metamask/controller-utils": true,
"@metamask/metamask-eth-abis": true,
"@metamask/utils": true,
"browserify>events": true,
"eth-json-rpc-filters>async-mutex": true,
"eth-query": true,
Expand All @@ -721,6 +722,27 @@
"uuid": true
}
},
"@metamask/assets-controllers>@metamask/abi-utils": {
"packages": {
"@metamask/utils": true,
"@metamask/utils>superstruct": true
}
},
"@metamask/assets-controllers>@metamask/controller-utils": {
"globals": {
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>isomorphic-fetch": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true
}
},
"@metamask/assets-controllers>abort-controller": {
"globals": {
"AbortController": true
Expand Down Expand Up @@ -1204,12 +1226,27 @@
},
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/controller-utils>isomorphic-fetch": true,
"@metamask/phishing-controller>@metamask/controller-utils": true,
"@metamask/phishing-controller>eth-phishing-detect": true,
"punycode": true
}
},
"@metamask/phishing-controller>@metamask/controller-utils": {
"globals": {
"console.error": true,
"fetch": true,
"setTimeout": true
},
"packages": {
"@metamask/controller-utils>isomorphic-fetch": true,
"browserify>buffer": true,
"eslint>fast-deep-equal": true,
"eth-ens-namehash": true,
"ethereumjs-util": true,
"ethjs>ethjs-unit": true
}
},
"@metamask/phishing-controller>eth-phishing-detect": {
"packages": {
"eslint>optionator>fast-levenshtein": true
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
"@metamask/address-book-controller": "^1.0.0",
"@metamask/announcement-controller": "^1.0.0",
"@metamask/approval-controller": "^1.0.0",
"@metamask/assets-controllers": "^3.0.1",
"@metamask/assets-controllers": "^4.0.1",
"@metamask/base-controller": "^1.0.0",
"@metamask/contract-metadata": "^2.2.0",
"@metamask/controller-utils": "^1.0.0",
Expand All @@ -238,7 +238,7 @@
"@metamask/notification-controller": "^1.0.0",
"@metamask/obs-store": "^5.0.0",
"@metamask/permission-controller": "^1.0.0",
"@metamask/phishing-controller": "^1.1.0",
"@metamask/phishing-controller": "^1.1.2",
"@metamask/post-message-stream": "^6.0.0",
"@metamask/providers": "^10.2.1",
"@metamask/rate-limit-controller": "^1.0.0",
Expand Down
43 changes: 43 additions & 0 deletions shared/constants/snaps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
///: BEGIN:ONLY_INCLUDE_IN(flask)
type SnapsMetadata = {
[snapId: string]: {
name: string;
};
};

// If a Snap ID is present in this object, its metadata is used before the info
// of the snap is fetched. Ideally this information would be fetched from the
// snap registry, but this is a temporary solution.
export const SNAPS_METADATA: SnapsMetadata = {
'npm:@metamask/test-snap-error': {
name: 'Error Test Snap',
},
'npm:@metamask/test-snap-confirm': {
name: 'Confirm Test Snap',
},
'npm:@metamask/test-snap-dialog': {
name: 'Dialog Test Snap',
},
'npm:@metamask/test-snap-bip44': {
name: 'BIP-44 Test Snap',
},
'npm:@metamask/test-snap-managestate': {
name: 'Manage State Test Snap',
},
'npm:@metamask/test-snap-notification': {
name: 'Notification Test Snap',
},
'npm:@metamask/test-snap-bip32': {
name: 'BIP-32 Test Snap',
},
'npm:@metamask/test-snap-insights': {
name: 'Insights Test Snap',
},
'npm:@metamask/test-snap-rpc': {
name: 'RPC Test Snap',
},
'npm:@metamask/test-snap-cronjob': {
name: 'Cronjob Test Snap',
},
};
///: END:ONLY_INCLUDE_IN
Loading

0 comments on commit 2c79659

Please sign in to comment.