mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
E2e improve mocking (#13841)
* improve mocking * improve mocking * Unnecessary await
This commit is contained in:
parent
442edc5a91
commit
d1c05195dd
@ -1,7 +1,7 @@
|
|||||||
function setupMocking(server, testSpecificMock) {
|
async function setupMocking(server, testSpecificMock) {
|
||||||
server.forAnyRequest().thenPassThrough();
|
await server.forAnyRequest().thenPassThrough();
|
||||||
|
|
||||||
server
|
await server
|
||||||
.forOptions('https://gas-api.metaswap.codefi.network/networks/1/gasPrices')
|
.forOptions('https://gas-api.metaswap.codefi.network/networks/1/gasPrices')
|
||||||
.thenCallback(() => {
|
.thenCallback(() => {
|
||||||
return {
|
return {
|
||||||
@ -14,7 +14,7 @@ function setupMocking(server, testSpecificMock) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
server
|
await server
|
||||||
.forGet('https://gas-api.metaswap.codefi.network/networks/1/gasPrices')
|
.forGet('https://gas-api.metaswap.codefi.network/networks/1/gasPrices')
|
||||||
.thenCallback(() => {
|
.thenCallback(() => {
|
||||||
return {
|
return {
|
||||||
|
@ -36,11 +36,12 @@ async function withFixtures(options, testSuite) {
|
|||||||
} = options;
|
} = options;
|
||||||
const fixtureServer = new FixtureServer();
|
const fixtureServer = new FixtureServer();
|
||||||
const ganacheServer = new Ganache();
|
const ganacheServer = new Ganache();
|
||||||
|
const https = await mockttp.generateCACertificate();
|
||||||
|
const mockServer = mockttp.getLocal({ https });
|
||||||
let secondaryGanacheServer;
|
let secondaryGanacheServer;
|
||||||
let dappServer;
|
let dappServer;
|
||||||
let segmentServer;
|
let segmentServer;
|
||||||
let segmentStub;
|
let segmentStub;
|
||||||
let mockServer;
|
|
||||||
|
|
||||||
let webDriver;
|
let webDriver;
|
||||||
let failed = false;
|
let failed = false;
|
||||||
@ -91,9 +92,7 @@ async function withFixtures(options, testSuite) {
|
|||||||
});
|
});
|
||||||
await segmentServer.start(9090);
|
await segmentServer.start(9090);
|
||||||
}
|
}
|
||||||
const https = await mockttp.generateCACertificate();
|
await setupMocking(mockServer, testSpecificMock);
|
||||||
mockServer = mockttp.getLocal({ https });
|
|
||||||
setupMocking(mockServer, testSpecificMock);
|
|
||||||
await mockServer.start(8000);
|
await mockServer.start(8000);
|
||||||
if (
|
if (
|
||||||
process.env.SELENIUM_BROWSER === 'chrome' &&
|
process.env.SELENIUM_BROWSER === 'chrome' &&
|
||||||
@ -157,9 +156,7 @@ async function withFixtures(options, testSuite) {
|
|||||||
if (segmentServer) {
|
if (segmentServer) {
|
||||||
await segmentServer.stop();
|
await segmentServer.stop();
|
||||||
}
|
}
|
||||||
if (mockServer) {
|
await mockServer.stop();
|
||||||
await mockServer.stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ const { strict: assert } = require('assert');
|
|||||||
const { convertToHexValue, withFixtures } = require('../helpers');
|
const { convertToHexValue, withFixtures } = require('../helpers');
|
||||||
|
|
||||||
describe('Phishing Detection', function () {
|
describe('Phishing Detection', function () {
|
||||||
function mockPhishingDetection(mockServer) {
|
async function mockPhishingDetection(mockServer) {
|
||||||
mockServer
|
await mockServer
|
||||||
.forGet(
|
.forGet(
|
||||||
'https://cdn.jsdelivr.net/gh/MetaMask/eth-phishing-detect@master/src/config.json',
|
'https://cdn.jsdelivr.net/gh/MetaMask/eth-phishing-detect@master/src/config.json',
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user