Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ const utilNumberImportBurndownFiles = [
'app/util/transactions/index.test.ts',
];

// Shared by the *.view.test.* and tests/component-view/** overrides so the
// fake-timer ban cannot drift. Covers the whole jest fake-timer API, `*Async`
// variants included.
const cvFakeTimerBan = {
selector:
"CallExpression[callee.object.name='jest'][callee.property.name=/^(useFakeTimers|useRealTimers|advanceTimersByTime(Async)?|advanceTimersToNextTimer(Async)?|runAllTimers(Async)?|runOnlyPendingTimers(Async)?|runAllTicks|setSystemTime|clearAllTimers)$/]",
message:
'Component-view tests must not use fake timers. Keep time behaviour in a unit test, or serve fixtures already in the target state. See docs/testing/component-view-tests.md.',
};

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -429,6 +439,27 @@ module.exports = {
message:
'Only Engine and react-native-device-info can be mocked in component-view tests.',
},
cvFakeTimerBan,
],
},
},
{
// Shared component-view helpers keep the base no-restricted-syntax bans
// and add the fake-timer ban. The jest.mock ban above does not apply
// here (mocks.ts mocks Engine).
files: ['tests/component-view/**/*.{ts,tsx}'],
rules: {
'no-restricted-syntax': [
'error',
{
selector: 'WithStatement',
message: 'With statements are not allowed',
},
{
selector: 'SequenceExpression',
message: 'Sequence expressions are not allowed',
},
cvFakeTimerBan,
],
},
},
Expand Down
Loading
Loading