From c28b86b5ff9433167c0a88b3f71966ba68ca3f11 Mon Sep 17 00:00:00 2001 From: Quantara CI Date: Fri, 26 Jun 2026 16:06:42 +0100 Subject: [PATCH 1/2] Add RN component snapshot tests --- TODO.md | 9 ++++++++ jest.config.js | 3 +++ .../common/Button.snapshot.test.tsx | 17 +++++++++++++++ src/components/common/Card.snapshot.test.tsx | 17 +++++++++++++++ .../SubscriptionCard.snapshot.test.tsx | 21 +++++++++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 TODO.md create mode 100644 src/components/common/Button.snapshot.test.tsx create mode 100644 src/components/common/Card.snapshot.test.tsx create mode 100644 src/components/subscription/SubscriptionCard.snapshot.test.tsx diff --git a/TODO.md b/TODO.md new file mode 100644 index 00000000..c5d34ed0 --- /dev/null +++ b/TODO.md @@ -0,0 +1,9 @@ +# TODO - Snapshot tests for key components + +- [ ] Ensure Jest is configured with the React Native snapshot serializer. +- [ ] Add snapshot test for `Button`. +- [ ] Add snapshot test for `Card`. +- [ ] Add snapshot test for `SubscriptionCard`. +- [ ] Run Jest to generate snapshots in version control. +- [ ] Create git branch `blackboxai/`, commit, and push to GitHub. + diff --git a/jest.config.js b/jest.config.js index 16174fe5..723b5496 100644 --- a/jest.config.js +++ b/jest.config.js @@ -19,5 +19,8 @@ module.exports = { '^@react-native-community/netinfo$': '/src/__mocks__/@react-native-community/netinfo.js', }, setupFilesAfterEnv: [], + // Ensure consistent React Native tree serialization for Jest snapshots. + snapshotSerializers: ['jest-expo/build/serializers/react-native'], testEnvironment: 'node', }; + diff --git a/src/components/common/Button.snapshot.test.tsx b/src/components/common/Button.snapshot.test.tsx new file mode 100644 index 00000000..7f846058 --- /dev/null +++ b/src/components/common/Button.snapshot.test.tsx @@ -0,0 +1,17 @@ +import React from 'react'; +import { Platform } from 'react-native'; +import { render } from '@testing-library/react-native'; +import { Button } from './Button'; + +describe('Button (snapshot)', () => { + it('renders default primary button', () => { + const { toJSON } = render(