-
-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tests): Flaky tests depending on execution order (client, stalltr…
…acking) (#3232)
- Loading branch information
1 parent
538cedb
commit a76d821
Showing
16 changed files
with
675 additions
and
627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,6 @@ import { | |
getSyncPromiseRejectOnFirstCall, | ||
} from './testutils'; | ||
|
||
const EXAMPLE_DSN = 'https://[email protected]/148053'; | ||
|
||
interface MockedReactNative { | ||
NativeModules: { | ||
RNSentry: { | ||
|
@@ -74,10 +72,10 @@ jest.mock( | |
alert: jest.fn(), | ||
}, | ||
}), | ||
/* virtual allows us to mock modules that aren't in package.json */ | ||
{ virtual: true }, | ||
); | ||
|
||
const EXAMPLE_DSN = 'https://[email protected]/148053'; | ||
|
||
const DEFAULT_OPTIONS: ReactNativeClientOptions = { | ||
enableNative: true, | ||
enableNativeCrashHandling: true, | ||
|
@@ -94,11 +92,6 @@ const DEFAULT_OPTIONS: ReactNativeClientOptions = { | |
stackParser: jest.fn().mockReturnValue([]), | ||
}; | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
NATIVE.enableNative = true; | ||
}); | ||
|
||
describe('Tests ReactNativeClient', () => { | ||
describe('initializing the client', () => { | ||
test('client initializes', async () => { | ||
|
@@ -110,7 +103,6 @@ describe('Tests ReactNativeClient', () => { | |
|
||
await expect(client.eventFromMessage('test')).resolves.toBeDefined(); | ||
// @ts-ignore: Is Mocked | ||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
await expect(RN.LogBox.ignoreLogs).toBeCalled(); | ||
}); | ||
|
||
|
@@ -150,9 +142,7 @@ describe('Tests ReactNativeClient', () => { | |
dsn: EXAMPLE_DSN, | ||
transport: myCustomTransportFn, | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
expect(client.getTransport()?.flush).toBe(myFlush); | ||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
expect(client.getTransport()?.send).toBe(mySend); | ||
}); | ||
}); | ||
|
@@ -212,6 +202,7 @@ describe('Tests ReactNativeClient', () => { | |
|
||
describe('nativeCrash', () => { | ||
test('calls NativeModules crash', () => { | ||
NATIVE.enableNative = true; | ||
const RN: MockedReactNative = require('react-native'); | ||
|
||
const client = new ReactNativeClient({ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
global.console = { | ||
...console, | ||
log: jest.fn(), | ||
debug: jest.fn(), | ||
info: jest.fn(), | ||
warn: jest.fn(), | ||
error: jest.fn(), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.