Skip to content

Commit

Permalink
tests(scanner): Update Jest snapshot file for `react-native-vision-ca…
Browse files Browse the repository at this point in the history
…mera`
  • Loading branch information
dorianvp committed Feb 12, 2025
1 parent 48965ad commit 1688f7c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
21 changes: 21 additions & 0 deletions __mocks__/react-native-vision-camera.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Simple mock for Camera
export const Camera = () => null;

// Mock that returns a mocked camera object
export const useCameraDevice = jest.fn(() => ({
id: 'mocked-camera',
name: 'Mock Camera',
position: 'back',
}));

// Mock that returns permission status and a request function
export const useCameraPermission = jest.fn(() => ({
hasPermission: true,
requestPermission: jest.fn(),
}));

// Mock that provides a mocked scanner function
export const useCodeScanner = jest.fn(() => ({
codeTypes: ['qr', 'ean-13'],
onCodeScanned: jest.fn(),
}));
4 changes: 1 addition & 3 deletions __tests__/__snapshots__/Scanner.snapshot.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ exports[`Component Scanner - test Scanner - snapshot 1`] = `
"width": "100%",
}
}
>
<mockQRCodeScanner />
</RCTSafeAreaView>
/>
`;
13 changes: 12 additions & 1 deletion metro.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');

const { resolver: defaultResolver } = getDefaultConfig.getDefaultValues();

/**
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('metro-config').MetroConfig}
*/
const config = {};

/**
* See https://react-native-vision-camera.com/docs/guides/mocking for more information.
*/
const config = {
resolver: {
...defaultResolver,
sourceExts: [process.env.RN_SRC_EXT && process.env.RN_SRC_EXT.split(','), ...defaultResolver.sourceExts],
},
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);

0 comments on commit 1688f7c

Please sign in to comment.