From 12f9e92b001e2efd03d04b79ae93015408f1bdcf Mon Sep 17 00:00:00 2001 From: Violet Caulfield <42452695+anultravioletaurora@users.noreply.github.com> Date: Thu, 3 Apr 2025 09:06:31 -0700 Subject: [PATCH] jest configuration Create jest folder, create setup.js file used after env --- jest.config.js | 1 + {__tests__ => jest}/App.test.tsx | 0 jest/setup.js | 35 ++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) rename {__tests__ => jest}/App.test.tsx (100%) create mode 100644 jest/setup.js diff --git a/jest.config.js b/jest.config.js index f558817e..3c3e31e1 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,6 +2,7 @@ module.exports = { preset: 'react-native', setupFiles: ["./node_modules/react-native-gesture-handler/jestSetup.js"], + setupFilesAfterEnv: ["./jest/setup.js"], extensionsToTreatAsEsm: ['.ts', '.tsx'], transformIgnorePatterns: [ 'node_modules/(?!((@)?react-native|react-native-url-polyfill|@react-navigation|react-native-track-player)/)', diff --git a/__tests__/App.test.tsx b/jest/App.test.tsx similarity index 100% rename from __tests__/App.test.tsx rename to jest/App.test.tsx diff --git a/jest/setup.js b/jest/setup.js new file mode 100644 index 00000000..4e54f33a --- /dev/null +++ b/jest/setup.js @@ -0,0 +1,35 @@ +// https://github.com/doublesymmetry/react-native-track-player/issues/501 +jest.mock('react-native-track-player', () => { + return { + addEventListener: jest.fn(), + registerEventHandler: jest.fn(), + registerPlaybackService: jest.fn(), + setupPlayer: jest.fn(), + destroy: jest.fn(), + updateOptions: jest.fn(), + add: jest.fn(), + remove: jest.fn(), + skip: jest.fn(), + skipToNext: jest.fn(), + skipToPrevious: jest.fn(), + removeUpcomingTracks: jest.fn(), + // playback commands + reset: jest.fn(), + play: jest.fn(), + pause: jest.fn(), + stop: jest.fn(), + seekTo: jest.fn(), + setVolume: jest.fn(), + setRate: jest.fn(), + // player getters + getQueue: jest.fn(), + getTrack: jest.fn(), + getCurrentTrack: jest.fn(), + getVolume: jest.fn(), + getDuration: jest.fn(), + getPosition: jest.fn(), + getBufferedPosition: jest.fn(), + getState: jest.fn(), + getRate: jest.fn(), + }; +}); \ No newline at end of file