Skip to content

Commit

Permalink
no snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Nov 10, 2020
1 parent fd94564 commit 9e7644e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 43 deletions.
3 changes: 1 addition & 2 deletions lighthouse-core/gather/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,7 @@ class Driver {
* @return {Promise<*>}
*/
async evaluateAsync(expression, options = {}) {
const contextId =
options.useIsolation ? await this._getOrCreateIsolatedContextId() : undefined;
const contextId = options.useIsolation ? await this._getOrCreateIsolatedContextId() : undefined;

try {
// `await` is not redundant here because we want to `catch` the async errors
Expand Down
76 changes: 35 additions & 41 deletions lighthouse-core/test/lib/page-functions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ describe('createEvalCode', () => {
const code = pageFunctions.createEvalCode(mainFn, {
mode: 'iife',
});
expect(code).toMatchInlineSnapshot(`
"(() => {
function mainFn() {
return true;
}
return mainFn();
})()"
`);
expect(code).toEqual(`(() => {
function mainFn() {
return true;
}
return mainFn();
})()`);
expect(eval(code)).toEqual(true);
});

Expand All @@ -47,27 +45,25 @@ describe('createEvalCode', () => {
deps: [abs, square],
mode: 'iife',
});
expect(code).toMatchInlineSnapshot(`
"(() => {
function abs(val) {
return Math.abs(val);
}
function square(val) {
return val * val;
}
function mainFn({
a,
b
}, passThru) {
return {
a: abs(a),
b: square(b),
passThru
};
}
return mainFn({\\"a\\":-5,\\"b\\":10},\\"hello\\");
})()"
`);
expect(code).toEqual(`(() => {
function abs(val) {
return Math.abs(val);
}
function square(val) {
return val * val;
}
function mainFn({
a,
b
}, passThru) {
return {
a: abs(a),
b: square(b),
passThru
};
}
return mainFn({"a":-5,"b":10},"hello");
})()`);
expect(eval(code)).toEqual({a: 5, b: 100, passThru: 'hello'});
});

Expand All @@ -83,17 +79,15 @@ describe('createEvalCode', () => {
mode: 'function',
deps: [adder],
});
expect(code).toMatchInlineSnapshot(`
"function () {
function adder(a, b) {
return a + b;
}
function mainFn(a, b) {
return adder(a, b);
}
return mainFn.call(this, 1,2);
}"
`);
expect(code).toEqual(`function () {
function adder(a, b) {
return a + b;
}
function mainFn(a, b) {
return adder(a, b);
}
return mainFn.call(this, 1,2);
}`);
expect(eval(`(${code})()`)).toEqual(3);
});
});
Expand Down

0 comments on commit 9e7644e

Please sign in to comment.