1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

allow importing of typescript in E2E test suite (#17141)

This commit is contained in:
Brad Decker 2023-01-12 09:38:12 -05:00 committed by GitHub
parent 1b62a773b4
commit 312f24fddc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 42 deletions

View File

@ -14,10 +14,10 @@
"build": "yarn lavamoat:build",
"build:dev": "node development/build/index.js",
"start:test": "SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' SENTRY_DSN_DEV=https://fake@sentry.io/0000000 PORTFOLIO_URL=http://127.0.0.1:8080 yarn build:dev testDev",
"benchmark:chrome": "SELENIUM_BROWSER=chrome node test/e2e/benchmark.js",
"mv3:stats:chrome": "SELENIUM_BROWSER=chrome ENABLE_MV3=true node test/e2e/mv3-perf-stats/index.js",
"user-actions-benchmark:chrome": "SELENIUM_BROWSER=chrome node test/e2e/user-actions-benchmark.js",
"benchmark:firefox": "SELENIUM_BROWSER=firefox node test/e2e/benchmark.js",
"benchmark:chrome": "SELENIUM_BROWSER=chrome ts-node test/e2e/benchmark.js",
"mv3:stats:chrome": "SELENIUM_BROWSER=chrome ENABLE_MV3=true ts-node test/e2e/mv3-perf-stats/index.js",
"user-actions-benchmark:chrome": "SELENIUM_BROWSER=chrome ts-node test/e2e/user-actions-benchmark.js",
"benchmark:firefox": "SELENIUM_BROWSER=firefox ts-node test/e2e/benchmark.js",
"build:test": "SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' SENTRY_DSN_DEV=https://fake@sentry.io/0000000 PORTFOLIO_URL=http://127.0.0.1:8080 yarn build test",
"build:test:flask": "yarn build test --build-type flask",
"build:test:mv3": "ENABLE_MV3=true SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' SENTRY_DSN_DEV=https://fake@sentry.io/0000000 PORTFOLIO_URL=http://127.0.0.1:8080 yarn build test",

5
test/e2e/.mocharc.js Normal file
View File

@ -0,0 +1,5 @@
// This file exists to add mocha configuration options specific to our
// E2E Test suite.
module.exports = {
require: ['test/e2e/e2e-mocha-setup.js'],
};

View File

@ -1,5 +1,4 @@
#!/usr/bin/env node
const path = require('path');
const { promises: fs } = require('fs');
const yargs = require('yargs/yargs');

View File

@ -0,0 +1,5 @@
// This file simply registers babel and ts-node so that we may use the same
// ECMAScript features in E2E tests that we use elsewhere in our code. It also
// allows values to be read from TypeScript files.
require('@babel/register');
require('ts-node/register');

View File

@ -1,4 +1,5 @@
const { merge } = require('lodash');
const { CHAIN_IDS } = require('../../shared/constants/network');
function defaultFixture() {
return {
@ -134,14 +135,14 @@ function defaultFixture() {
showTestnetMessageInDropdown: true,
trezorModel: null,
usedNetworks: {
'0x1': true,
'0x5': true,
'0x539': true,
[CHAIN_IDS.MAINNET]: true,
[CHAIN_IDS.GOERLI]: true,
[CHAIN_IDS.LOCALHOST]: true,
},
},
CachedBalancesController: {
cachedBalances: {
'0x539': {},
[CHAIN_IDS.LOCALHOST]: {},
},
},
CurrencyController: {
@ -159,9 +160,9 @@ function defaultFixture() {
IncomingTransactionsController: {
incomingTransactions: {},
incomingTxLastFetchedBlockByChainId: {
'0x1': null,
'0x5': null,
'0xaa36a7': null,
[CHAIN_IDS.MAINNET]: null,
[CHAIN_IDS.GOERLI]: null,
[CHAIN_IDS.SEPOLIA]: null,
},
},
KeyringController: {
@ -178,7 +179,7 @@ function defaultFixture() {
NetworkController: {
network: '1337',
provider: {
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
nickname: 'Localhost 8545',
rpcPrefs: {},
rpcUrl: 'http://localhost:8545',
@ -205,7 +206,7 @@ function defaultFixture() {
forgottenPassword: false,
frequentRpcListDetail: [
{
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
nickname: 'Localhost 8545',
rpcPrefs: {},
rpcUrl: 'http://localhost:8545',
@ -245,7 +246,7 @@ function defaultFixture() {
fees: {},
liveness: true,
smartTransactions: {
'0x1': [],
[CHAIN_IDS.MAINNET]: [],
},
},
},
@ -300,9 +301,9 @@ function onboardingFixture() {
showTestnetMessageInDropdown: true,
trezorModel: null,
usedNetworks: {
'0x1': true,
'0x5': true,
'0x539': true,
[CHAIN_IDS.MAINNET]: true,
[CHAIN_IDS.GOERLI]: true,
[CHAIN_IDS.LOCALHOST]: true,
},
},
NetworkController: {
@ -311,7 +312,7 @@ function onboardingFixture() {
ticker: 'ETH',
type: 'rpc',
rpcUrl: 'http://localhost:8545',
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
nickname: 'Localhost 8545',
},
},
@ -325,7 +326,7 @@ function onboardingFixture() {
forgottenPassword: false,
frequentRpcListDetail: [
{
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
nickname: 'Localhost 8545',
rpcPrefs: {},
rpcUrl: 'http://localhost:8545',
@ -358,7 +359,7 @@ function onboardingFixture() {
fees: {},
liveness: true,
smartTransactions: {
'0x1': [],
[CHAIN_IDS.MAINNET]: [],
},
},
},
@ -450,7 +451,7 @@ class FixtureBuilder {
incomingTransactions: {
'0xf1af8286e4fa47578c2aec5f08c108290643df978ebc766d72d88476eee90bab': {
blockNumber: '1',
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
hash: '0xf1af8286e4fa47578c2aec5f08c108290643df978ebc766d72d88476eee90bab',
id: 5748272735958807,
metamaskNetworkId: '1337',
@ -656,14 +657,14 @@ class FixtureBuilder {
return this.withTransactionController({
transactions: {
7911313280012623: {
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
dappSuggestedGasFees: {
gas: '0x5208',
gasPrice: '0x4a817c800',
},
history: [
{
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
dappSuggestedGasFees: {
gas: '0x5208',
gasPrice: '0x4a817c800',
@ -709,14 +710,14 @@ class FixtureBuilder {
type: 'simpleSend',
},
7911313280012624: {
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
dappSuggestedGasFees: {
gas: '0x5208',
gasPrice: '0x4a817c800',
},
history: [
{
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
dappSuggestedGasFees: {
gas: '0x5208',
gasPrice: '0x4a817c800',
@ -762,14 +763,14 @@ class FixtureBuilder {
type: 'simpleSend',
},
7911313280012625: {
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
dappSuggestedGasFees: {
gas: '0x5208',
gasPrice: '0x4a817c800',
},
history: [
{
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
dappSuggestedGasFees: {
gas: '0x5208',
gasPrice: '0x4a817c800',
@ -815,14 +816,14 @@ class FixtureBuilder {
type: 'simpleSend',
},
7911313280012626: {
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
dappSuggestedGasFees: {
gas: '0x5208',
gasPrice: '0x4a817c800',
},
history: [
{
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
dappSuggestedGasFees: {
gas: '0x5208',
gasPrice: '0x4a817c800',
@ -875,10 +876,10 @@ class FixtureBuilder {
return this.withTransactionController({
transactions: {
4046084157914634: {
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
history: [
{
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
id: 4046084157914634,
loadingDefaults: true,
metamaskNetworkId: '1337',
@ -909,7 +910,7 @@ class FixtureBuilder {
metamaskNetworkId: '1337',
origin: 'metamask',
primaryTransaction: {
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
id: 4046084157914634,
loadingDefaults: true,
metamaskNetworkId: '1337',
@ -944,10 +945,10 @@ class FixtureBuilder {
return this.withTransactionController({
transactions: {
4046084157914634: {
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
history: [
{
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
id: 4046084157914634,
loadingDefaults: true,
metamaskNetworkId: '1337',
@ -980,7 +981,7 @@ class FixtureBuilder {
metamaskNetworkId: '1337',
origin: 'metamask',
primaryTransaction: {
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
id: 4046084157914634,
loadingDefaults: true,
metamaskNetworkId: '1337',
@ -1019,10 +1020,10 @@ class FixtureBuilder {
return this.withTransactionController({
transactions: {
4046084157914634: {
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
history: [
{
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
id: 4046084157914634,
loadingDefaults: true,
metamaskNetworkId: '1337',
@ -1091,7 +1092,7 @@ class FixtureBuilder {
metamaskNetworkId: '1337',
origin: 'metamask',
primaryTransaction: {
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
id: 4046084157914634,
loadingDefaults: true,
metamaskNetworkId: '1337',
@ -1130,10 +1131,10 @@ class FixtureBuilder {
return this.withTransactionController({
transactions: {
5748272735958801: {
chainId: '0x539',
chainId: CHAIN_IDS.LOCALHOST,
history: [
{
chainId: 0x539,
chainId: CHAIN_IDS.LOCALHOST,
id: 5748272735958801,
loadingDefaults: true,
metamaskNetworkId: '1337',

View File

@ -1,4 +1,5 @@
const { promises: fs } = require('fs');
const path = require('path');
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const { runInShell } = require('../../development/lib/run-command');
@ -88,10 +89,12 @@ async function main() {
exit = '--no-exit';
}
const configFile = path.join(__dirname, '.mocharc.js');
await retry({ retries }, async () => {
await runInShell('yarn', [
'mocha',
'--no-config',
`--config=${configFile}`,
'--timeout',
testTimeoutInMilliseconds,
e2eTestPath,