refactor: do less

This commit is contained in:
cha0s 2024-02-14 22:35:10 -06:00
parent 1c6c4755cc
commit 58a840c359
2 changed files with 26 additions and 10 deletions

View File

@ -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;
}
};
}

View File

@ -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,
));