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'});
|
const {payload: config} = await socket.send({type: 'config.get', payload: '@flecks/web'});
|
||||||
this.timeout(previousTimeout + (Date.now() - start));
|
this.timeout(previousTimeout + (Date.now() - start));
|
||||||
const {browser, page} = await createBrowser(optionsWithTask);
|
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);
|
const response = await connectPage(page, `http://${config.public}`, optionsWithTask);
|
||||||
return task({
|
let taskError;
|
||||||
browser,
|
try {
|
||||||
page,
|
await task({
|
||||||
response,
|
browser,
|
||||||
server,
|
page,
|
||||||
socket,
|
response,
|
||||||
task: this,
|
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(
|
it('brings a client up', withWeb(
|
||||||
async ({
|
async ({
|
||||||
browser,
|
|
||||||
page,
|
page,
|
||||||
response,
|
response,
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -37,7 +36,6 @@ it('brings a client up', withWeb(
|
||||||
.to.deep.equal({why: 'hello there'});
|
.to.deep.equal({why: 'hello there'});
|
||||||
expect(request)
|
expect(request)
|
||||||
.to.equal('testing-value-value');
|
.to.equal('testing-value-value');
|
||||||
await browser.close();
|
|
||||||
},
|
},
|
||||||
options,
|
options,
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user