1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Refactor Errors E2E test to no longer rely upon a real error (#17332)

Co-authored-by: Danica Shen <zhaodanica@gmail.com>
This commit is contained in:
Brad Decker 2023-01-23 12:58:35 -06:00 committed by GitHub
parent b746bd0866
commit d2c3abea51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -43,12 +43,7 @@ describe('Sentry errors', function () {
await driver.fill('#password', 'correct horse battery staple');
await driver.press('#password', driver.Key.ENTER);
// Trigger error
await driver.clickElement('[data-testid="eth-overview-send"]');
await driver.fill(
'input[placeholder="Search, public address (0x), or ENS"]',
'0x2f318C334780961FB129D2a6c30D0763d9a5C970',
);
await driver.fill('input[placeholder="0"]', `-01`);
driver.executeScript('window.stateHooks.throwTestError()');
// Wait for Sentry request
await driver.wait(async () => {
const isPending = await mockedEndpoint.isPending();
@ -60,11 +55,8 @@ describe('Sentry errors', function () {
const [{ type, value }] = mockJsonBody.exception.values;
const { participateInMetaMetrics } = extra.appState.store.metamask;
// Verify request
assert.equal(type, 'BigNumber Error');
assert.equal(
value,
'new BigNumber() not a base 16 number: 0x-de0b6b3a7640000',
);
assert.equal(type, 'TestError');
assert.equal(value, 'Test Error');
assert.equal(level, 'error');
assert.equal(participateInMetaMetrics, true);
},

View File

@ -164,6 +164,15 @@ async function startApp(metamaskState, backgroundConnection, opts) {
}
function setupDebuggingHelpers(store) {
/**
* The following stateHook is a method intended to throw an error, used in
* our E2E test to ensure that errors are attempted to be sent to sentry.
*/
window.stateHooks.throwTestError = async function () {
const error = new Error('Test Error');
error.name = 'TestError';
throw error;
};
window.stateHooks.getCleanAppState = async function () {
const state = clone(store.getState());
state.version = global.platform.getVersion();