mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 20:39:08 +01:00
cc928aaed9
The `withFixtures` helper will instantiate ganache, a web driver, and a fixture server initialized with the given set of fixtures. It is meant to facilitating writing small, isolated e2e tests. The first example test has been added: simple-send. It ensures that the user can send 1 ETH to another account. These new e2e tests will run during the normal e2e test run. Closes #6548
41 lines
996 B
JavaScript
41 lines
996 B
JavaScript
const path = require('path')
|
|
const Ganache = require('./ganache')
|
|
const FixtureServer = require('./fixture-server')
|
|
const { buildWebDriver } = require('./webdriver')
|
|
|
|
const tinyDelayMs = 200
|
|
const regularDelayMs = tinyDelayMs * 2
|
|
const largeDelayMs = regularDelayMs * 2
|
|
|
|
async function withFixtures (options, callback) {
|
|
const { fixtures, ganacheOptions, driverOptions } = options
|
|
const fixtureServer = new FixtureServer()
|
|
const ganacheServer = new Ganache()
|
|
|
|
let webDriver
|
|
try {
|
|
await ganacheServer.start(ganacheOptions)
|
|
await fixtureServer.start()
|
|
await fixtureServer.loadState(path.join(__dirname, 'fixtures', fixtures))
|
|
const { driver } = await buildWebDriver(driverOptions)
|
|
webDriver = driver
|
|
|
|
await callback({
|
|
driver,
|
|
})
|
|
} finally {
|
|
await fixtureServer.stop()
|
|
await ganacheServer.quit()
|
|
if (webDriver) {
|
|
await webDriver.quit()
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
tinyDelayMs,
|
|
regularDelayMs,
|
|
largeDelayMs,
|
|
withFixtures,
|
|
}
|