I just called jest src/containers/components/VerificationView.test.js --runTestsByPath --verbose
and it just has 1 simple test:
import React from 'react';
import { render, act, fireEvent, waitFor } from '@testing-library/react-native';
import VerificationView from './VerificationView';
describe('Verification Screen', () => {
beforeEach(() => {
jest.useFakeTimers();
});
afterEach(() => {
jest.runAllTimers();
})
it('should render without errors', async () => {
const verificationRes = {VerificationR: {status:1}};
const login = jest.fn();
const authContextValue = { login }; // Mock the context value
var wrapper = render(
<VerificationView />
);
await wrapper.update();
expect(wrapper).toMatchSnapshot();
});
});
but the test run calls many other files:
PASS src/containers/components/VerificationView.test.js
RenderLang component
✓ should render without errors (24 ms)
✓ should call handler onPress (7 ms)
✓ render while activeLang is selected (3 ms)
✓ render while activeLang is not selected (2 ms)
Signup component
✓ Signup component renders correctly (55 ms)
✓ Signup login button press (24 ms)
✓ Signup back button press (17 ms)
✓ Signup btnTNC button press (20 ms)
✓ Signup btnSignup button press (17 ms)
✓ Signup setPassword change text (18 ms)
✓ Signup setPassword change text (18 ms)
✓ Signup setPhone change text (16 ms)
✓ Signup setPhone change text empty (29 ms)
✓ Signup setEmail change text (18 ms)
✓ Signup setLName change text (16 ms)
✓ Signup setFName change text (18 ms)
Verification Screen
✓ should render without errors (31 ms)
And a snip from my jest.config.js
testMatch: [
"<rootDir>/src/**/*.test.js"
],
testPathIgnorePatterns: ["/node_modules/", "e2e/", "__mocks__/"],
testEnvironmentOptions: { url: 'http://localhost/' },
//transform: {
// //"^.+\\.(js|jsx)$": "<rootDir>/jest.preprocessor.js"
//},
transform: {
//"^.+\\.(js|jsx)$": "<rootDir>/jest.preprocessor.js",
"^.+\\.js$": "babel-jest"
},
//transform: {
// '^.+\\.(js|jsx|ts|tsx)$': [
// 'babel-jest',
// { configFile: './babel.config.js' }, // <- cannot use rootDir here
// ],
//},
transformIgnorePatterns: [
//"/node_modules/(?!(jest-)?@codler)",
//"node_modules/.*/react-native-vector-icons.*",
//"node_modules/(?!(@react-native|react-native|native-base.*|react-native-easy-grid|react-native-drawer|@react-native-community|react-native-vector-icons)/)",
"node_modules\/(?!(@react-native|react-native|native-base.*|react-native-element-dropdown|react-native-image-crop-picker|react-native-easy-grid|react-native-drawer|@react-native-community|@react-native-firebase|react-native-vector-icons|@codler|@twotalltotems/react-native-otp-input|react-native-iphone-x-helper|@react-native-picker|rn-range-slider|react-native-i18n|react-native-flash-message|react-native-linear-gradient|react-native-simple-radio-button|react-native-picker-select|react-native-config)\/)"
],
Please suggest.