Skip to content

feat(breaking): migrate Flow to TS; remove some deprecated functions and aliases #881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 25, 2022
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
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ jobs:
root: .
paths:
- .
lint-and-flow:
lint-and-typescript:
<<: *defaults
steps:
- attach_workspace:
at: ~/react-native-testing-library
- run: |
yarn lint
yarn flow-check
typescript:
yarn typecheck
flow:
<<: *defaults
steps:
- attach_workspace:
at: ~/react-native-testing-library
- run: |
yarn typescript-check
yarn flow
tests:
<<: *defaults
steps:
Expand Down Expand Up @@ -89,10 +89,10 @@ workflows:
build-and-test:
jobs:
- install-dependencies
- lint-and-flow:
- lint-and-typescript:
requires:
- install-dependencies
- typescript:
- flow:
requires:
- install-dependencies
- tests:
Expand Down
2 changes: 2 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ node_modules/warning/.*
.*/node_modules/@react-native-community/cli/.*/.*

[include]
.*/typings/

[libs]
node_modules/react-native/interface.js
node_modules/react-native/flow/
flow-typed/
.*/typings/index

[options]
server.max_workers=4
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ test('form submits two answers', () => {
const allQuestions = ['q1', 'q2'];
const mockFn = jest.fn();

const { getAllByA11yLabel, getByText } = render(
const { getAllByLabelText, getByText } = render(
<QuestionsBoard questions={allQuestions} onSubmit={mockFn} />
);

const answerInputs = getAllByA11yLabel('answer input');
const answerInputs = getAllByLabelText('answer input');

fireEvent.changeText(answerInputs[0], 'a1');
fireEvent.changeText(answerInputs[1], 'a2');
Expand Down
8 changes: 7 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
presets: [
'@babel/preset-flow',
'@babel/preset-typescript',
'@babel/preset-react',
[
'@babel/preset-env',
Expand All @@ -13,4 +13,10 @@ module.exports = {
],
],
plugins: ['@babel/plugin-proposal-class-properties'],
env: {
test: {
// https://github.com/react-native-community/upgrade-support/issues/152
plugins: ['@babel/plugin-transform-flow-strip-types'],
},
},
};
38 changes: 24 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@testing-library/react-native",
"version": "9.1.0",
"description": "Simple and complete React Native testing utilities that encourage good testing practices.",
"main": "build/index.js",
"typings": "./typings/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://www.github.com/callstack/react-native-testing-library.git"
Expand All @@ -21,26 +21,31 @@
"files": [
"build/",
"jest-preset/",
"typings/index.d.ts",
"typings/index.flow.js",
"pure.js",
"dont-cleanup-after-each.js"
],
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-transform-flow-strip-types": "^7.16.0",
"@babel/preset-env": "^7.9.6",
"@babel/preset-flow": "^7.9.0",
"@babel/preset-react": "^7.9.4",
"@babel/preset-typescript": "^7.16.0",
"@callstack/eslint-config": "^11.0.0",
"@release-it/conventional-changelog": "^2.0.0",
"@testing-library/jest-native": "~4.0.2",
"@types/jest": "^27.0.0",
"@types/react": "^17.0.0",
"@types/react-native": "^0.66.5",
"@types/react-native": "^0.66.6",
"@types/react-test-renderer": "^17.0.0",
"babel-jest": "^27.0.0",
"conventional-changelog-cli": "^2.0.11",
"cp-cli": "^2.0.0",
"dedent": "^0.7.0",
"del-cli": "^3.0.1",
"eslint": "^7.0.0",
"flow-bin": "^0.141.0",
"flow-copy-source": "^2.0.9",
Expand All @@ -61,25 +66,30 @@
"react-test-renderer": ">=16.0.0"
},
"scripts": {
"clean": "del build",
"test": "jest",
"flow-check": "flow check",
"typescript-check": "tsc --noEmit --skipLibCheck --jsx react ./typings/__tests__/*",
"typecheck": "tsc",
"flow": "flow",
"copy-flowtypes": "cp typings/index.flow.js build",
"lint": "eslint src --cache",
"release": "release-it",
"prepublish": "yarn build && yarn copy-flowtypes",
"copy-flowtypes": "flow-copy-source --ignore __tests__/*.js src build",
"build": "rm -rf build; babel src --out-dir build --ignore 'src/__tests__/*'"
"prepublish": "yarn build",
"build:js": "babel src --out-dir build --extensions \".js,.ts\" --source-maps --ignore \"**/__tests__/**\"",
"build:js:watch": "yarn build:js --watch",
"build:ts": "tsc --build tsconfig.release.json",
"build:ts:watch": "yarn build:ts --watch --preserveWatchOutput",
"build": "yarn clean && yarn build:js && yarn build:ts && yarn copy-flowtypes",
"prepare": "yarn build"
},
"jest": {
"preset": "../jest-preset",
"moduleFileExtensions": [
"js",
"json"
],
"rootDir": "./src",
"testPathIgnorePatterns": [
"timerUtils"
],
"testTimeout": 30000
"testTimeout": 30000,
"transformIgnorePatterns": [
"/node_modules/(?!(@react-native|react-native)/).*/"
]
}
}
Loading