Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf committed Sep 1, 2022
1 parent 49d5593 commit 9aede4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/common/Frame.ts
Expand Up @@ -872,8 +872,13 @@ export class Frame {
element = document.createElement('style');
element.appendChild(document.createTextNode(content!));
}
let resolve: undefined | ((value?: unknown) => void);
const promise = new Promise((res, rej) => {
element.addEventListener('load', res, {once: true});
if (!url) {
element.addEventListener('load', res, {once: true});
} else {
resolve = res;
}
element.addEventListener(
'error',
event => {
Expand All @@ -887,6 +892,9 @@ export class Frame {
);
});
document.head.appendChild(element);
if (resolve) {
resolve();
}
await promise;
return element;
},
Expand Down
2 changes: 1 addition & 1 deletion test/src/page.spec.ts
Expand Up @@ -1797,7 +1797,7 @@ describe('Page', function () {
error = error_ as Error;
}
expect(error.message).toBe(
'Provide an object with a `url`, `path` or `content` property'
'Exactly one of `url`, `path`, or `content` may be specified.'
);
});

Expand Down

0 comments on commit 9aede4e

Please sign in to comment.