-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from white-label-loyalty/feature/testing
Feature/testing
- Loading branch information
Showing
86 changed files
with
4,838 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.18.0 | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Run tests | ||
run: yarn test | ||
|
||
- name: Type check | ||
run: yarn type-check | ||
|
||
- name: Build | ||
run: yarn build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module.exports = api => { | ||
const isTest = api.env('test'); | ||
|
||
return { | ||
presets: [ | ||
['module:metro-react-native-babel-preset', { modules: false }] | ||
], | ||
plugins: [ | ||
['module-resolver', { | ||
alias: { | ||
'^react-native$': 'react-native-web' | ||
} | ||
}] | ||
], | ||
env: { | ||
test: { | ||
presets: [ | ||
['@babel/preset-env', { targets: { node: 'current' }, modules: 'commonjs' }], | ||
'@babel/preset-typescript', | ||
['@babel/preset-react', { runtime: 'automatic' }] | ||
] | ||
}, | ||
production: { | ||
presets: [ | ||
['@babel/preset-env', { modules: false }], | ||
'@babel/preset-typescript', | ||
['@babel/preset-react', { runtime: 'automatic' }] | ||
] | ||
} | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
presets: [ | ||
['@babel/preset-env', { modules: false }], | ||
'@babel/preset-typescript', | ||
['@babel/preset-react', { runtime: 'automatic' }] | ||
], | ||
plugins: [ | ||
['module-resolver', { | ||
alias: { | ||
'^react-native$': 'react-native-web' | ||
} | ||
}] | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module.exports = { | ||
preset: 'react-native', | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'd.ts'], | ||
transform: { | ||
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', | ||
'^.+\\.svg$': 'jest-transform-stub', | ||
}, | ||
testEnvironment: 'jsdom', | ||
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'], | ||
moduleNameMapper: { | ||
'^react-native$': 'react-native-web', | ||
'\\.(jpg|jpeg|png|gif|webp|svg)$': 'jest-transform-stub', | ||
}, | ||
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$', | ||
testPathIgnorePatterns: ['/node_modules/', '/dist/', '\\.d\\.ts$'], | ||
coveragePathIgnorePatterns: ['/node_modules/', '/dist/'], | ||
transformIgnorePatterns: [ | ||
'node_modules/(?!(react-native|react-native-web|@react-native|@react-native-community|@react-navigation)/)', | ||
], | ||
globals: { | ||
'ts-jest': { | ||
babelConfig: true, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import '@testing-library/jest-dom'; | ||
import '@testing-library/jest-native/extend-expect'; | ||
|
||
// Suppress specific console warnings during tests | ||
const originalConsoleWarn = console.warn; | ||
console.warn = (...args) => { | ||
// Add any warning messages you want to filter here | ||
const warningsToSuppress = [ | ||
'accessibilityLabel', | ||
'aria-label', | ||
'style.resizeMode is deprecated' | ||
]; | ||
|
||
// Check if the warning message includes any of the suppressed warnings | ||
const shouldSuppress = warningsToSuppress.some(warning => | ||
args.some(arg => typeof arg === 'string' && arg.includes(warning)) | ||
); | ||
|
||
if (!shouldSuppress) { | ||
originalConsoleWarn(...args); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import '@testing-library/jest-dom'; | ||
|
||
declare global { | ||
namespace jest { | ||
interface Matchers<R> { | ||
toBeInTheDocument(): R; | ||
toBeEmptyDOMElement(): R; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { WllSdkProvider } from '../../context/WllSdkContext'; | ||
import { defaultTheme } from '../../utils/styling'; | ||
|
||
const defaultConfig = { | ||
apiKey: 'test-api-key', | ||
userToken: 'test-user-token', | ||
}; | ||
|
||
const AllTheProviders = ({ children }: { children: React.ReactNode }) => { | ||
return ( | ||
<WllSdkProvider | ||
config={defaultConfig} | ||
theme={defaultTheme} | ||
navigationConfig={{}} | ||
> | ||
{children} | ||
</WllSdkProvider> | ||
); | ||
}; | ||
|
||
const customRender = (ui: React.ReactElement, options = {}) => | ||
render(ui, { wrapper: AllTheProviders, ...options }); | ||
|
||
// re-export everything | ||
export * from '@testing-library/react'; | ||
|
||
// override render method | ||
export { customRender as render }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* istanbul ignore file */ | ||
import React, { useRef } from 'react'; | ||
import { | ||
Animated, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.