Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,20 @@ exclude_patterns:
- "**/*.yml"
- "**/build.gradle"
- "**/AndroidManifest.xml"
plugins:
eslint:
enabled: true
editorconfig:
enabled: true
fixme:
enabled: true
git-legal:
enabled: true
shellcheck:
enabled: true
swiftlint:
enabled: true
tailor:
enabled: true
tslint:
enabled: true
27 changes: 0 additions & 27 deletions .github/workflows/test-and-publish.yml

This file was deleted.

53 changes: 53 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Unit Tests

on:
push:
branches:
- "master"
pull_request:
branches:
- "**"

jobs:
test-comment:
name: Unit tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Run tests
run: |
yarn test --coverage --coverageReporters json-summary

- name: Test coverage comment
id: coverageComment
uses: MishaKav/jest-coverage-comment@main
with:
hide-comment: false
coverage-summary-path: ./coverage/coverage-summary.json
test-code-climate:
name: Upload unit test results to Code Climate
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup

- name: Run tests
run: |
yarn test --coverage --coverageReporters lcov

- name: Upload coverage to Code Climate
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: yarn test --coverage --coverageReporters lcov
coverageLocations: |
${{github.workspace}}/coverage/lcov.info:lcov
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@ android/generated

# Iterable
.env
.xcode.env.local
.xcode.env.local
coverage/
28 changes: 25 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
module.exports = {
preset: 'react-native',
setupFiles: ['<rootDir>/ts/__mocks__/jest.setup.ts'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
testMatch: ['<rootDir>/ts/__tests__/**/*.(test|spec).[jt]s?(x)'],
setupFiles: ['<rootDir>/src/__mocks__/jest.setup.ts'],
setupFilesAfterEnv: [
'<rootDir>/node_modules/@testing-library/jest-native/extend-expect',
],
testMatch: ['<rootDir>/src/__tests__/**/*.(test|spec).[jt]s?(x)'],
transformIgnorePatterns: [
'node_modules/(?!((jest-)?react-native(-.*)?|@react-native(-community)?)/)',
],
collectCoverageFrom: [
'src/**/*.{cjs,js,jsx,mjs,ts,tsx}',
'!src/**/*.test.{cjs,js,jsx,mjs,mdx,ts,tsx}',
'!src/(__tests__|__mocks__)/*',
],
modulePathIgnorePatterns: [
'<rootDir>/example/node_modules',
'<rootDir>/lib/',
],
coverageThreshold: {
global: {
branches: 10,
functions: 30,
lines: 30,
statements: 30,
},
},
};
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"scripts": {
"example": "yarn workspace @iterable/react-native-sdk-example",
"test": "jest",
"test:coverage": "jest --coverage",
"typecheck": "tsc",
"lint": "eslint \"**/*.{js,ts,tsx}\"",
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
Expand Down Expand Up @@ -69,6 +70,8 @@
"@react-native/eslint-config": "^0.73.1",
"@react-navigation/native": "^6.1.18",
"@release-it/conventional-changelog": "^5.0.0",
"@testing-library/jest-native": "^5.4.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked up the jest-native library and it is indicated as deprecated. Is this a concern?
https://github.com/testing-library/jest-native

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The react-native library is the correct recommended version.

"@testing-library/react-native": "^12.7.2",
"@types/jest": "^29.5.5",
"@types/react": "^18.2.44",
"@types/react-native-vector-icons": "^6.4.18",
Expand Down Expand Up @@ -104,13 +107,6 @@
"example"
],
"packageManager": "[email protected]",
"jest": {
"preset": "react-native",
"modulePathIgnorePatterns": [
"<rootDir>/example/node_modules",
"<rootDir>/lib/"
]
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
Expand Down
10 changes: 9 additions & 1 deletion src/__mocks__/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import * as ReactNative from 'react-native';

import { MockRNIterableAPI } from './MockRNIterableAPI';
import { MockLinking } from './MockLinking';

import * as ReactNative from 'react-native';
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter.js');

jest.mock('react-native-webview', () => {
const { View } = require('react-native');
return {
WebView: View,
};
});

jest.doMock('react-native', () => {
// Extend ReactNative
return Object.setPrototypeOf(
Expand Down
Loading
Loading