diff --git a/__tests__/App-test.tsx b/__tests__/App-test.tsx deleted file mode 100644 index ed3487371..000000000 --- a/__tests__/App-test.tsx +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @format - */ - -import 'react-native'; -import React from 'react'; -import Root from '../src/Root'; - -// Note: test renderer must be required after react-native. -import renderer from 'react-test-renderer'; - -it('renders correctly', () => { - renderer.create(); -}); diff --git a/__tests__/Checkbox.tsx b/__tests__/Checkbox.tsx new file mode 100644 index 000000000..ec4a2a3b5 --- /dev/null +++ b/__tests__/Checkbox.tsx @@ -0,0 +1,13 @@ +import React from 'react'; +import renderer from 'react-test-renderer'; +import Checkbox from '../src/components/checkbox/Checkbox'; +import { Text } from 'react-native'; + +it('renders correctly', () => { + const tree = renderer + .create( {}} checked={true}> + toggle + ) + .toJSON(); + expect(tree).toMatchSnapshot(); +}); diff --git a/__tests__/__snapshots__/Checkbox.tsx.snap b/__tests__/__snapshots__/Checkbox.tsx.snap new file mode 100644 index 000000000..00a26ce26 --- /dev/null +++ b/__tests__/__snapshots__/Checkbox.tsx.snap @@ -0,0 +1,75 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders correctly 1`] = ` + + + + + + +`; diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 000000000..1aa54488a --- /dev/null +++ b/jest.config.js @@ -0,0 +1,18 @@ +module.exports = { + 'preset': 'react-native', + 'moduleFileExtensions': [ + 'ts', + 'tsx', + 'js', + 'jsx', + 'json', + 'node' + ], + 'transformIgnorePatterns': [ + 'node_modules/(?!(@freakycoder|@react-native|react-native|rn-fetch|redux-persist-filesystem|@react-navigation' + + '|@react-native-community|react-navigation|react-navigation-redux-helpers|@sentry))' + ], + 'transform': { + '^.+\\.svg$': 'jest-svg-transformer' + } +}; \ No newline at end of file diff --git a/package.json b/package.json index 67c3b45a0..55f0332b8 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "android:build:debug": "./scripts/android-debug.sh", "lint": "eslint --fix . --ext .js,.jsx,.ts,.tsx", "postinstall": "./scripts/postinstall.sh", - "clean": "react-native-clean-project" + "clean": "react-native-clean-project", + "pod:install": "command -v pod && (cd ios/ && pod install && cd ..) || echo \"pod command not found\"" }, "dependencies": { "@freakycoder/react-native-bounceable": "^0.2.5", @@ -85,6 +86,7 @@ "babel-loader": "^8.2.3", "eslint": "^7.14.0", "jest": "^26.6.3", + "jest-svg-transformer": "^1.0.0", "metro-react-native-babel-preset": "^0.64.0", "react-dom": "17.0.1", "react-native-clean-project": "^3.6.7", @@ -96,17 +98,6 @@ "resolutions": { "@types/react": "^17" }, - "jest": { - "preset": "react-native", - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "jsx", - "json", - "node" - ] - }, "react-native": { "crypto": "react-native-crypto", "http": "@tradle/react-native-http", diff --git a/yarn.lock b/yarn.lock index ab02ecc93..7e19c1372 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7385,6 +7385,11 @@ jest-snapshot@^26.6.2: pretty-format "^26.6.2" semver "^7.3.2" +jest-svg-transformer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/jest-svg-transformer/-/jest-svg-transformer-1.0.0.tgz#e38884ca4cd8b2295cdfa2a0b24667920c3a8a6d" + integrity sha1-44iEykzYsilc36KgskZnkgw6im0= + jest-util@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.6.2.tgz#907535dbe4d5a6cb4c47ac9b926f6af29576cbc1"