refactor: do less
This commit is contained in:
parent
1c6c4755cc
commit
58a840c359
|
@ -16,14 +16,32 @@ export function withWeb(task, options) {
|
|||
const {payload: config} = await socket.send({type: 'config.get', payload: '@flecks/web'});
|
||||
this.timeout(previousTimeout + (Date.now() - start));
|
||||
const {browser, page} = await createBrowser(optionsWithTask);
|
||||
if (options.beforePage) {
|
||||
await options.beforePage({
|
||||
browser,
|
||||
page,
|
||||
server,
|
||||
socket,
|
||||
});
|
||||
}
|
||||
const response = await connectPage(page, `http://${config.public}`, optionsWithTask);
|
||||
return task({
|
||||
browser,
|
||||
page,
|
||||
response,
|
||||
server,
|
||||
socket,
|
||||
task: this,
|
||||
});
|
||||
let taskError;
|
||||
try {
|
||||
await task({
|
||||
browser,
|
||||
page,
|
||||
response,
|
||||
server,
|
||||
socket,
|
||||
task: this,
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
taskError = error;
|
||||
}
|
||||
await browser.close();
|
||||
if (taskError) {
|
||||
throw taskError;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ const options = {
|
|||
|
||||
it('brings a client up', withWeb(
|
||||
async ({
|
||||
browser,
|
||||
page,
|
||||
response,
|
||||
}) => {
|
||||
|
@ -37,7 +36,6 @@ it('brings a client up', withWeb(
|
|||
.to.deep.equal({why: 'hello there'});
|
||||
expect(request)
|
||||
.to.equal('testing-value-value');
|
||||
await browser.close();
|
||||
},
|
||||
options,
|
||||
));
|
||||
|
|
Loading…
Reference in New Issue
Block a user