Async setup of environment with Jest
问题 Before running e2e tests in Jest I need to get an authentication token from the server. Is it possible to do this globally one and set it somehow to the global environment / context for each test ? I tried it with globalSetup config option: const auth = require('./src/auth') const ctx = require('./src/context') module.exports = () => { return new Promise(res => { auth.getToken() .then(token => { ctx.init({token}) global.token = token res() }) }) } context.js let _token const init = ({token})