diff --git a/.eslintignore b/.eslintignore index 9d278399b..2ba0ace08 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,3 @@ -__tests__ node_modules *.js *.d.ts diff --git a/jest.config.js b/jest.config.js index fdf981545..e6583c8ed 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,7 +2,7 @@ module.exports = { clearMocks: true, coverageDirectory: 'coverage', moduleDirectories: ['node_modules', 'src'], - modulePathIgnorePatterns: ['IapExample'], + modulePathIgnorePatterns: ['IapExample', 'lib'], preset: 'react-native', setupFiles: ['/test/mocks/react-native-modules.js'], setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect'], diff --git a/package.json b/package.json index 8eefcc332..3d38f406b 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,8 @@ "!**/__mocks__" ], "scripts": { - "prepare": "bob build", + "prepare": "yarn lint && yarn test && yarn build", + "build": "bob build", "release": "release-it", "example": "yarn --cwd IapExample", "test": "jest", diff --git a/src/__tests__/iap.test.ts b/src/__tests__/iap.test.ts index 2f8eb9c90..4542d8fa3 100644 --- a/src/__tests__/iap.test.ts +++ b/src/__tests__/iap.test.ts @@ -2,16 +2,15 @@ import {NativeModules} from 'react-native'; import {initConnection} from '../iap'; -const rnLib = '../../node_modules/react-native/Libraries'; +jest.mock( + '../../node_modules/react-native/Libraries/Utilities/Platform', + () => ({ + OS: 'android', + select: (dict: {[x: string]: any}) => dict.android, + }), +); describe('Google Play IAP', () => { - beforeEach(() => { - jest.mock(rnLib + '/Utilities/Platform', () => ({ - OS: 'android', - select: (dict: {[x: string]: any}) => dict.android, - })); - }); - it("should call init on Google Play's native module but not on Amazon's", async () => { await initConnection(); expect(NativeModules.RNIapModule.initConnection).toBeCalled(); diff --git a/tsconfig.json b/tsconfig.json index 9597aea37..d99623741 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,5 +24,6 @@ "skipLibCheck": true, "strict": true, "target": "esnext" - } + }, + "exclude": ["IapExample", "lib"] }