mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-01-12 17:42:24 +08:00
33
.github/workflows/tests_jest.yml
vendored
Normal file
33
.github/workflows/tests_jest.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
name: Testing
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- '**'
|
||||
|
||||
jobs:
|
||||
jest:
|
||||
name: Jest
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- uses: actions/cache@v1
|
||||
name: Yarn Cache
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- name: Yarn Install
|
||||
run: yarn --no-audit --prefer-offline
|
||||
- name: Jest
|
||||
run: yarn run tests:jest-coverage
|
||||
@@ -10,6 +10,20 @@ module.exports = {
|
||||
],
|
||||
],
|
||||
},
|
||||
test: {
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
targets: {
|
||||
node: 'current',
|
||||
},
|
||||
},
|
||||
],
|
||||
'module:./tests/node_modules/metro-react-native-babel-preset',
|
||||
'@babel/preset-flow',
|
||||
],
|
||||
},
|
||||
publish: {
|
||||
presets: [
|
||||
[
|
||||
|
||||
8
jest.config.js
Normal file
8
jest.config.js
Normal file
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
maxConcurrency: 10,
|
||||
preset: './tests/node_modules/react-native/jest-preset.js',
|
||||
setupFiles: ['./jest.setup.js'],
|
||||
testMatch: ['**/packages/**/__tests__/**/*.test.js'],
|
||||
modulePaths: ['node_modules', './tests/node_modules'],
|
||||
testPathIgnorePatterns: ['./packages/template'],
|
||||
};
|
||||
26
jest.setup.js
Normal file
26
jest.setup.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import * as ReactNative from 'react-native';
|
||||
|
||||
jest.doMock('react-native', () => {
|
||||
return Object.setPrototypeOf(
|
||||
{
|
||||
Platform: {
|
||||
OS: 'android',
|
||||
},
|
||||
NativeModules: {
|
||||
...ReactNative.NativeModules,
|
||||
RNFBAppModule: {
|
||||
NATIVE_FIREBASE_APPS: [
|
||||
{
|
||||
appConfig: {
|
||||
name: '[DEFAULT]',
|
||||
},
|
||||
options: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
RNFBPerfModule: {},
|
||||
},
|
||||
},
|
||||
ReactNative,
|
||||
);
|
||||
});
|
||||
26
package.json
26
package.json
@@ -11,6 +11,9 @@
|
||||
"lerna:bootstrap": "lerna bootstrap",
|
||||
"lerna:link": "lerna link",
|
||||
"lerna:clean": "lerna clean",
|
||||
"tests:jest": "jest",
|
||||
"tests:jest-watch": "jest --watch",
|
||||
"tests:jest-coverage": "jest --coverage",
|
||||
"gen:reference": "node scripts/generate-typedoc.js",
|
||||
"tests:packager:chrome": "cd tests && node_modules/.bin/react-native start --reset-cache",
|
||||
"tests:packager:jet": "cd tests && cross-env REACT_DEBUGGER=\"echo nope\" node_modules/.bin/react-native start --no-interactive",
|
||||
@@ -31,23 +34,26 @@
|
||||
"format:markdown": "prettier --write \"docs/**/*.md\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"inquirer": "^7.1.0",
|
||||
"shelljs": "^0.8.3",
|
||||
"codecov": "^3.6.5",
|
||||
"cross-env": "^7.0.2",
|
||||
"genversion": "^2.2.0",
|
||||
"lerna": "3.20.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"typedoc": "^0.15.0",
|
||||
"typescript": "^3.8.3",
|
||||
"@types/react-native": "^0.62.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.18.0",
|
||||
"@typescript-eslint/parser": "^2.18.0",
|
||||
"codecov": "^3.6.5",
|
||||
"cross-env": "^7.0.2",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.5.0",
|
||||
"eslint-plugin-prettier": "^3.1.1",
|
||||
"eslint-plugin-react": "^7.19.0",
|
||||
"prettier": "^1.19.1"
|
||||
"genversion": "^2.2.0",
|
||||
"inquirer": "^7.1.0",
|
||||
"lerna": "3.20.2",
|
||||
"prettier": "^1.19.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"shelljs": "^0.8.3",
|
||||
"typedoc": "^0.15.0",
|
||||
"typescript": "^3.8.3",
|
||||
"jest": "^24.9.0",
|
||||
"@babel/preset-env": "7.9.5",
|
||||
"@babel/preset-flow": "7.9.0"
|
||||
},
|
||||
"workspaces": {
|
||||
"packages": [
|
||||
|
||||
@@ -64,3 +64,5 @@ android/.settings
|
||||
.circleci
|
||||
.eslintignore
|
||||
type-test.ts
|
||||
|
||||
__tests__
|
||||
|
||||
12
packages/functions/__tests__/functions.test.js
Normal file
12
packages/functions/__tests__/functions.test.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import functions from '../lib';
|
||||
|
||||
describe('Cloud Functions', () => {
|
||||
describe('useFunctionsEmulator()', () => {
|
||||
it('useFunctionsEmulator -> uses 10.0.2.2', () => {
|
||||
functions().useFunctionsEmulator('http://localhost');
|
||||
expect(functions()._useFunctionsEmulatorOrigin).toBe('http://10.0.2.2');
|
||||
functions().useFunctionsEmulator('http://127.0.0.1');
|
||||
expect(functions()._useFunctionsEmulatorOrigin).toBe('http://10.0.2.2');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -64,3 +64,5 @@ android/.settings
|
||||
.circleci
|
||||
.eslintignore
|
||||
type-test.ts
|
||||
|
||||
__tests__
|
||||
|
||||
9
packages/perf/__tests__/perf.test.js
Normal file
9
packages/perf/__tests__/perf.test.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import perf from '../lib';
|
||||
|
||||
describe('Performance Monitoring', () => {
|
||||
describe('setPerformanceCollectionEnabled', () => {
|
||||
it('errors if not boolean', async () => {
|
||||
expect(() => perf().setPerformanceCollectionEnabled()).toThrow('must be a boolean');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user