mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
allow importing of typescript in E2E test suite (#17141)
This commit is contained in:
parent
1b62a773b4
commit
312f24fddc
@ -14,10 +14,10 @@
|
|||||||
"build": "yarn lavamoat:build",
|
"build": "yarn lavamoat:build",
|
||||||
"build:dev": "node development/build/index.js",
|
"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",
|
"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",
|
"benchmark:chrome": "SELENIUM_BROWSER=chrome ts-node test/e2e/benchmark.js",
|
||||||
"mv3:stats:chrome": "SELENIUM_BROWSER=chrome ENABLE_MV3=true node test/e2e/mv3-perf-stats/index.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 node test/e2e/user-actions-benchmark.js",
|
"user-actions-benchmark:chrome": "SELENIUM_BROWSER=chrome ts-node test/e2e/user-actions-benchmark.js",
|
||||||
"benchmark:firefox": "SELENIUM_BROWSER=firefox node test/e2e/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": "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: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",
|
"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
5
test/e2e/.mocharc.js
Normal 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'],
|
||||||
|
};
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { promises: fs } = require('fs');
|
const { promises: fs } = require('fs');
|
||||||
const yargs = require('yargs/yargs');
|
const yargs = require('yargs/yargs');
|
||||||
|
5
test/e2e/e2e-mocha-setup.js
Normal file
5
test/e2e/e2e-mocha-setup.js
Normal 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');
|
@ -1,4 +1,5 @@
|
|||||||
const { merge } = require('lodash');
|
const { merge } = require('lodash');
|
||||||
|
const { CHAIN_IDS } = require('../../shared/constants/network');
|
||||||
|
|
||||||
function defaultFixture() {
|
function defaultFixture() {
|
||||||
return {
|
return {
|
||||||
@ -134,14 +135,14 @@ function defaultFixture() {
|
|||||||
showTestnetMessageInDropdown: true,
|
showTestnetMessageInDropdown: true,
|
||||||
trezorModel: null,
|
trezorModel: null,
|
||||||
usedNetworks: {
|
usedNetworks: {
|
||||||
'0x1': true,
|
[CHAIN_IDS.MAINNET]: true,
|
||||||
'0x5': true,
|
[CHAIN_IDS.GOERLI]: true,
|
||||||
'0x539': true,
|
[CHAIN_IDS.LOCALHOST]: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CachedBalancesController: {
|
CachedBalancesController: {
|
||||||
cachedBalances: {
|
cachedBalances: {
|
||||||
'0x539': {},
|
[CHAIN_IDS.LOCALHOST]: {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CurrencyController: {
|
CurrencyController: {
|
||||||
@ -159,9 +160,9 @@ function defaultFixture() {
|
|||||||
IncomingTransactionsController: {
|
IncomingTransactionsController: {
|
||||||
incomingTransactions: {},
|
incomingTransactions: {},
|
||||||
incomingTxLastFetchedBlockByChainId: {
|
incomingTxLastFetchedBlockByChainId: {
|
||||||
'0x1': null,
|
[CHAIN_IDS.MAINNET]: null,
|
||||||
'0x5': null,
|
[CHAIN_IDS.GOERLI]: null,
|
||||||
'0xaa36a7': null,
|
[CHAIN_IDS.SEPOLIA]: null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
KeyringController: {
|
KeyringController: {
|
||||||
@ -178,7 +179,7 @@ function defaultFixture() {
|
|||||||
NetworkController: {
|
NetworkController: {
|
||||||
network: '1337',
|
network: '1337',
|
||||||
provider: {
|
provider: {
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
nickname: 'Localhost 8545',
|
nickname: 'Localhost 8545',
|
||||||
rpcPrefs: {},
|
rpcPrefs: {},
|
||||||
rpcUrl: 'http://localhost:8545',
|
rpcUrl: 'http://localhost:8545',
|
||||||
@ -205,7 +206,7 @@ function defaultFixture() {
|
|||||||
forgottenPassword: false,
|
forgottenPassword: false,
|
||||||
frequentRpcListDetail: [
|
frequentRpcListDetail: [
|
||||||
{
|
{
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
nickname: 'Localhost 8545',
|
nickname: 'Localhost 8545',
|
||||||
rpcPrefs: {},
|
rpcPrefs: {},
|
||||||
rpcUrl: 'http://localhost:8545',
|
rpcUrl: 'http://localhost:8545',
|
||||||
@ -245,7 +246,7 @@ function defaultFixture() {
|
|||||||
fees: {},
|
fees: {},
|
||||||
liveness: true,
|
liveness: true,
|
||||||
smartTransactions: {
|
smartTransactions: {
|
||||||
'0x1': [],
|
[CHAIN_IDS.MAINNET]: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -300,9 +301,9 @@ function onboardingFixture() {
|
|||||||
showTestnetMessageInDropdown: true,
|
showTestnetMessageInDropdown: true,
|
||||||
trezorModel: null,
|
trezorModel: null,
|
||||||
usedNetworks: {
|
usedNetworks: {
|
||||||
'0x1': true,
|
[CHAIN_IDS.MAINNET]: true,
|
||||||
'0x5': true,
|
[CHAIN_IDS.GOERLI]: true,
|
||||||
'0x539': true,
|
[CHAIN_IDS.LOCALHOST]: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
NetworkController: {
|
NetworkController: {
|
||||||
@ -311,7 +312,7 @@ function onboardingFixture() {
|
|||||||
ticker: 'ETH',
|
ticker: 'ETH',
|
||||||
type: 'rpc',
|
type: 'rpc',
|
||||||
rpcUrl: 'http://localhost:8545',
|
rpcUrl: 'http://localhost:8545',
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
nickname: 'Localhost 8545',
|
nickname: 'Localhost 8545',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -325,7 +326,7 @@ function onboardingFixture() {
|
|||||||
forgottenPassword: false,
|
forgottenPassword: false,
|
||||||
frequentRpcListDetail: [
|
frequentRpcListDetail: [
|
||||||
{
|
{
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
nickname: 'Localhost 8545',
|
nickname: 'Localhost 8545',
|
||||||
rpcPrefs: {},
|
rpcPrefs: {},
|
||||||
rpcUrl: 'http://localhost:8545',
|
rpcUrl: 'http://localhost:8545',
|
||||||
@ -358,7 +359,7 @@ function onboardingFixture() {
|
|||||||
fees: {},
|
fees: {},
|
||||||
liveness: true,
|
liveness: true,
|
||||||
smartTransactions: {
|
smartTransactions: {
|
||||||
'0x1': [],
|
[CHAIN_IDS.MAINNET]: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -450,7 +451,7 @@ class FixtureBuilder {
|
|||||||
incomingTransactions: {
|
incomingTransactions: {
|
||||||
'0xf1af8286e4fa47578c2aec5f08c108290643df978ebc766d72d88476eee90bab': {
|
'0xf1af8286e4fa47578c2aec5f08c108290643df978ebc766d72d88476eee90bab': {
|
||||||
blockNumber: '1',
|
blockNumber: '1',
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
hash: '0xf1af8286e4fa47578c2aec5f08c108290643df978ebc766d72d88476eee90bab',
|
hash: '0xf1af8286e4fa47578c2aec5f08c108290643df978ebc766d72d88476eee90bab',
|
||||||
id: 5748272735958807,
|
id: 5748272735958807,
|
||||||
metamaskNetworkId: '1337',
|
metamaskNetworkId: '1337',
|
||||||
@ -656,14 +657,14 @@ class FixtureBuilder {
|
|||||||
return this.withTransactionController({
|
return this.withTransactionController({
|
||||||
transactions: {
|
transactions: {
|
||||||
7911313280012623: {
|
7911313280012623: {
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
dappSuggestedGasFees: {
|
dappSuggestedGasFees: {
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
gasPrice: '0x4a817c800',
|
gasPrice: '0x4a817c800',
|
||||||
},
|
},
|
||||||
history: [
|
history: [
|
||||||
{
|
{
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
dappSuggestedGasFees: {
|
dappSuggestedGasFees: {
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
gasPrice: '0x4a817c800',
|
gasPrice: '0x4a817c800',
|
||||||
@ -709,14 +710,14 @@ class FixtureBuilder {
|
|||||||
type: 'simpleSend',
|
type: 'simpleSend',
|
||||||
},
|
},
|
||||||
7911313280012624: {
|
7911313280012624: {
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
dappSuggestedGasFees: {
|
dappSuggestedGasFees: {
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
gasPrice: '0x4a817c800',
|
gasPrice: '0x4a817c800',
|
||||||
},
|
},
|
||||||
history: [
|
history: [
|
||||||
{
|
{
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
dappSuggestedGasFees: {
|
dappSuggestedGasFees: {
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
gasPrice: '0x4a817c800',
|
gasPrice: '0x4a817c800',
|
||||||
@ -762,14 +763,14 @@ class FixtureBuilder {
|
|||||||
type: 'simpleSend',
|
type: 'simpleSend',
|
||||||
},
|
},
|
||||||
7911313280012625: {
|
7911313280012625: {
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
dappSuggestedGasFees: {
|
dappSuggestedGasFees: {
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
gasPrice: '0x4a817c800',
|
gasPrice: '0x4a817c800',
|
||||||
},
|
},
|
||||||
history: [
|
history: [
|
||||||
{
|
{
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
dappSuggestedGasFees: {
|
dappSuggestedGasFees: {
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
gasPrice: '0x4a817c800',
|
gasPrice: '0x4a817c800',
|
||||||
@ -815,14 +816,14 @@ class FixtureBuilder {
|
|||||||
type: 'simpleSend',
|
type: 'simpleSend',
|
||||||
},
|
},
|
||||||
7911313280012626: {
|
7911313280012626: {
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
dappSuggestedGasFees: {
|
dappSuggestedGasFees: {
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
gasPrice: '0x4a817c800',
|
gasPrice: '0x4a817c800',
|
||||||
},
|
},
|
||||||
history: [
|
history: [
|
||||||
{
|
{
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
dappSuggestedGasFees: {
|
dappSuggestedGasFees: {
|
||||||
gas: '0x5208',
|
gas: '0x5208',
|
||||||
gasPrice: '0x4a817c800',
|
gasPrice: '0x4a817c800',
|
||||||
@ -875,10 +876,10 @@ class FixtureBuilder {
|
|||||||
return this.withTransactionController({
|
return this.withTransactionController({
|
||||||
transactions: {
|
transactions: {
|
||||||
4046084157914634: {
|
4046084157914634: {
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
history: [
|
history: [
|
||||||
{
|
{
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
id: 4046084157914634,
|
id: 4046084157914634,
|
||||||
loadingDefaults: true,
|
loadingDefaults: true,
|
||||||
metamaskNetworkId: '1337',
|
metamaskNetworkId: '1337',
|
||||||
@ -909,7 +910,7 @@ class FixtureBuilder {
|
|||||||
metamaskNetworkId: '1337',
|
metamaskNetworkId: '1337',
|
||||||
origin: 'metamask',
|
origin: 'metamask',
|
||||||
primaryTransaction: {
|
primaryTransaction: {
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
id: 4046084157914634,
|
id: 4046084157914634,
|
||||||
loadingDefaults: true,
|
loadingDefaults: true,
|
||||||
metamaskNetworkId: '1337',
|
metamaskNetworkId: '1337',
|
||||||
@ -944,10 +945,10 @@ class FixtureBuilder {
|
|||||||
return this.withTransactionController({
|
return this.withTransactionController({
|
||||||
transactions: {
|
transactions: {
|
||||||
4046084157914634: {
|
4046084157914634: {
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
history: [
|
history: [
|
||||||
{
|
{
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
id: 4046084157914634,
|
id: 4046084157914634,
|
||||||
loadingDefaults: true,
|
loadingDefaults: true,
|
||||||
metamaskNetworkId: '1337',
|
metamaskNetworkId: '1337',
|
||||||
@ -980,7 +981,7 @@ class FixtureBuilder {
|
|||||||
metamaskNetworkId: '1337',
|
metamaskNetworkId: '1337',
|
||||||
origin: 'metamask',
|
origin: 'metamask',
|
||||||
primaryTransaction: {
|
primaryTransaction: {
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
id: 4046084157914634,
|
id: 4046084157914634,
|
||||||
loadingDefaults: true,
|
loadingDefaults: true,
|
||||||
metamaskNetworkId: '1337',
|
metamaskNetworkId: '1337',
|
||||||
@ -1019,10 +1020,10 @@ class FixtureBuilder {
|
|||||||
return this.withTransactionController({
|
return this.withTransactionController({
|
||||||
transactions: {
|
transactions: {
|
||||||
4046084157914634: {
|
4046084157914634: {
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
history: [
|
history: [
|
||||||
{
|
{
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
id: 4046084157914634,
|
id: 4046084157914634,
|
||||||
loadingDefaults: true,
|
loadingDefaults: true,
|
||||||
metamaskNetworkId: '1337',
|
metamaskNetworkId: '1337',
|
||||||
@ -1091,7 +1092,7 @@ class FixtureBuilder {
|
|||||||
metamaskNetworkId: '1337',
|
metamaskNetworkId: '1337',
|
||||||
origin: 'metamask',
|
origin: 'metamask',
|
||||||
primaryTransaction: {
|
primaryTransaction: {
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
id: 4046084157914634,
|
id: 4046084157914634,
|
||||||
loadingDefaults: true,
|
loadingDefaults: true,
|
||||||
metamaskNetworkId: '1337',
|
metamaskNetworkId: '1337',
|
||||||
@ -1130,10 +1131,10 @@ class FixtureBuilder {
|
|||||||
return this.withTransactionController({
|
return this.withTransactionController({
|
||||||
transactions: {
|
transactions: {
|
||||||
5748272735958801: {
|
5748272735958801: {
|
||||||
chainId: '0x539',
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
history: [
|
history: [
|
||||||
{
|
{
|
||||||
chainId: 0x539,
|
chainId: CHAIN_IDS.LOCALHOST,
|
||||||
id: 5748272735958801,
|
id: 5748272735958801,
|
||||||
loadingDefaults: true,
|
loadingDefaults: true,
|
||||||
metamaskNetworkId: '1337',
|
metamaskNetworkId: '1337',
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const { promises: fs } = require('fs');
|
const { promises: fs } = require('fs');
|
||||||
|
const path = require('path');
|
||||||
const yargs = require('yargs/yargs');
|
const yargs = require('yargs/yargs');
|
||||||
const { hideBin } = require('yargs/helpers');
|
const { hideBin } = require('yargs/helpers');
|
||||||
const { runInShell } = require('../../development/lib/run-command');
|
const { runInShell } = require('../../development/lib/run-command');
|
||||||
@ -88,10 +89,12 @@ async function main() {
|
|||||||
exit = '--no-exit';
|
exit = '--no-exit';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const configFile = path.join(__dirname, '.mocharc.js');
|
||||||
|
|
||||||
await retry({ retries }, async () => {
|
await retry({ retries }, async () => {
|
||||||
await runInShell('yarn', [
|
await runInShell('yarn', [
|
||||||
'mocha',
|
'mocha',
|
||||||
'--no-config',
|
`--config=${configFile}`,
|
||||||
'--timeout',
|
'--timeout',
|
||||||
testTimeoutInMilliseconds,
|
testTimeoutInMilliseconds,
|
||||||
e2eTestPath,
|
e2eTestPath,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user