Skip to content

Commit cd1abf6

Browse files
authored
Merge pull request #382 from vip-git/jest
feat: jest and typescript integration
2 parents 7e0e0f3 + 5a289f4 commit cd1abf6

218 files changed

Lines changed: 36199 additions & 6269 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.babelrc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44
"plugins": [
55
"react-hot-loader/babel"
66
]
7+
},
8+
"test": {
9+
"presets": [
10+
[
11+
"@babel/preset-env", { "targets": { "node": "current" }}
12+
],
13+
["@babel/preset-react", {"targets": {"node": "current"}}]
14+
],
15+
"plugins": [
16+
[
17+
"@babel/plugin-proposal-class-properties", { "loose": true }
18+
],
19+
"@babel/plugin-transform-runtime"
20+
]
721
}
822
},
923
"presets": [
@@ -15,7 +29,7 @@
1529
"useBuiltIns": "usage",
1630
"modules": false,
1731
"corejs" : "3",
18-
"sourceType": "unambiguous",
32+
"sourceType": "unambiguous"
1933
}],
2034
"@babel/preset-react"
2135
],

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build/
2+
.eslintrc.js
3+
__tests__
4+
dist
5+
__e2e__
6+
jest.config.js

.eslintrc.js

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@ module.exports = {
22
'extends': [
33
'airbnb',
44
'plugin:react-hooks/recommended',
5+
'eslint:recommended',
6+
'plugin:@typescript-eslint/recommended',
7+
'plugin:@typescript-eslint/recommended-requiring-type-checking'
58
],
9+
'parser': '@typescript-eslint/parser',
10+
'plugins': ['@typescript-eslint', 'jest', 'import'],
611
'rules': {
12+
'react/jsx-filename-extension': [2, { 'extensions': ['.js', '.jsx', '.ts', '.tsx'] }],
13+
'no-use-before-define': [0],
14+
'@typescript-eslint/no-use-before-define': [1],
15+
'no-tabs': 'off', // enable it later stage
716
'import/no-extraneous-dependencies': 'off',
17+
'import/no-unresolved': 'off',
18+
'import/extensions': 'off',
819
'no-trailing-spaces': 'off',
920
'react/jsx-indent': 'off',
1021
'no-unused-vars': 'off',
@@ -28,9 +39,39 @@ module.exports = {
2839
'brace-style': ['error', 'stroustrup'],
2940
'no-plusplus': 'off',
3041
'object-curly-newline': 'off',
42+
'@typescript-eslint/no-var-requires': 'off',
43+
'@typescript-eslint/restrict-template-expressions': 'off',
44+
'@typescript-eslint/restrict-plus-operands': 'off',
45+
'@typescript-eslint/no-explicit-any': 'off', // enable this later stage
46+
'@typescript-eslint/ban-types': 'off', // enable this later stage
47+
'@typescript-eslint/no-unsafe-assignment': 'off', // enable this later stage
48+
'@typescript-eslint/no-unsafe-member-access': 'off', // enable this later stage
49+
'@typescript-eslint/explicit-module-boundary-types': 'off', // enable this later stage
50+
'@typescript-eslint/no-unsafe-return': 'off', // enable this later stage
51+
'@typescript-eslint/no-unsafe-call': 'off', // enable this later stage
52+
'@typescript-eslint/no-unused-vars': 'off' // enable this later stage
53+
},
54+
'settings': {
55+
react: {
56+
version: 'detect' // Tells eslint-plugin-react to automatically detect the version of React to use
57+
},
58+
'import/resolver': {
59+
node: {
60+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
61+
paths: ['./src', './src/types']
62+
}
63+
},
64+
},
65+
'parserOptions': {
66+
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
67+
sourceType: 'module', // Allows for the use of imports
68+
ecmaFeatures: {
69+
jsx: true, // Allows for the parsing of JSX
70+
legacyDecorators: true
71+
},
72+
project: './tsconfig.json'
3173
},
32-
'parser': 'babel-eslint',
3374
'env': {
34-
'jest/globals': true,
75+
'jest/globals': true
3576
},
3677
};

.github/workflows/node-e2e.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Test E2E CI
5+
6+
on:
7+
pull_request:
8+
branches: [main]
9+
types: [opened, synchronize, closed]
10+
pull_request_target:
11+
branches: [ main ]
12+
13+
jobs:
14+
build:
15+
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
node-version: [14.x] # Add support for 12.x, 15.x later just build and unit tests
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: Run E2E Test ${{ matrix.node-version }}
25+
uses: actions/setup-node@v1
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
- run: npm install
29+
- name: "Check if deployment is done"
30+
env:
31+
VERCEL_TOKEN: ${{secrets.VERCEL_TOKEN}}
32+
VERCEL_API: ${{secrets.VERCEL_API}}
33+
run : |
34+
isReadyState()
35+
{
36+
GIT_SHA=$(git log -1 --pretty=%B | grep ^Merge | cut -d " " -f 2)
37+
VERCEL_STATE=$(curl -H "$VERCEL_TOKEN" "$VERCEL_API$GIT_SHA" | jq -r '.deployments[0].state')
38+
if [ $VERCEL_STATE = "READY" ]; then
39+
echo Valid state $VERCEL_STATE
40+
elif [ $VERCEL_STATE = "ERROR" ]; then
41+
echo InValid state $VERCEL_STATE 1>&2
42+
exit 64
43+
elif [ $VERCEL_STATE = "null" ]; then
44+
echo InValid state $VERCEL_STATE 1>&2
45+
exit 64
46+
else
47+
echo invalid state found - $VERCEL_STATE
48+
isReadyState
49+
fi
50+
}
51+
isReadyState
52+
- run: |
53+
GIT_SHA=$(git log -1 --pretty=%B | grep ^Merge | cut -d " " -f 2)
54+
VERCEL_URI=$(curl -H "$VERCEL_TOKEN" "$VERCEL_API$GIT_SHA" | jq -r '.deployments[0].url')
55+
echo ${VERCEL_URI} for ${GITHUB_SHA} with ${GIT_SHA} - ${GITHUB_REF} - ${GITHUB_HEAD_REF} - ${VERCEL_API}
56+
VERCEL_URL="https://${VERCEL_URI}" npm run test:e2e:ci
57+
env:
58+
BROWSERSTACK_USER: ${{secrets.BROWSERSTACK_USER}}
59+
BROWSERSTACK_ACCESSKEY: ${{secrets.BROWSERSTACK_ACCESSKEY}}
60+
VERCEL_TOKEN: ${{secrets.VERCEL_TOKEN}}
61+
VERCEL_API: ${{secrets.VERCEL_API}}

.github/workflows/node.js.yml

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,5 @@ jobs:
2626
with:
2727
node-version: ${{ matrix.node-version }}
2828
- run: npm install
29-
- run: npm test
30-
- name: "Check if deployment is done"
31-
env:
32-
VERCEL_TOKEN: ${{secrets.VERCEL_TOKEN}}
33-
VERCEL_API: ${{secrets.VERCEL_API}}
34-
run : |
35-
isReadyState()
36-
{
37-
GIT_SHA=$(git log -1 --pretty=%B | grep ^Merge | cut -d " " -f 2)
38-
VERCEL_STATE=$(curl -H "$VERCEL_TOKEN" "$VERCEL_API$GIT_SHA" | jq -r '.deployments[0].state')
39-
if [ $VERCEL_STATE = "READY" ]; then
40-
echo Valid state $VERCEL_STATE
41-
elif [ $VERCEL_STATE = "ERROR" ]; then
42-
echo InValid state $VERCEL_STATE 1>&2
43-
exit 64
44-
elif [ $VERCEL_STATE = "null" ]; then
45-
echo InValid state $VERCEL_STATE 1>&2
46-
exit 64
47-
else
48-
echo invalid state found - $VERCEL_STATE
49-
isReadyState
50-
fi
51-
}
52-
isReadyState
53-
- run: |
54-
GIT_SHA=$(git log -1 --pretty=%B | grep ^Merge | cut -d " " -f 2)
55-
VERCEL_URI=$(curl -H "$VERCEL_TOKEN" "$VERCEL_API$GIT_SHA" | jq -r '.deployments[0].url')
56-
echo ${VERCEL_URI} for ${GITHUB_SHA} with ${GIT_SHA} - ${GITHUB_REF} - ${GITHUB_HEAD_REF} - ${VERCEL_API}
57-
VERCEL_URL="https://${VERCEL_URI}" npm run test:e2e:ci
58-
env:
59-
BROWSERSTACK_USER: ${{secrets.BROWSERSTACK_USER}}
60-
BROWSERSTACK_ACCESSKEY: ${{secrets.BROWSERSTACK_ACCESSKEY}}
61-
VERCEL_TOKEN: ${{secrets.VERCEL_TOKEN}}
62-
VERCEL_API: ${{secrets.VERCEL_API}}
29+
- run: npm run build
30+
- run: npx jest --env=jsdom --config=jest.config.js --coverage --ci --updateSnapshot --detectOpenHandles --forceExit

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ _results_
99
.DS_Store
1010
generator/package-lock.json
1111
generator/package.json
12+
coverage
13+
.husky
14+
src/fields/components/**/package-lock.json

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ wdio.conf.js
3131
changelog.md
3232
contributing.md
3333
Dockerfile
34+
__tests__
35+
.husky

.prettierrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
...require('gts/.prettierrc.json')
3+
}

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN mkdir -p /opt/react-json-schema
1414
WORKDIR /opt/react-json-schema
1515
COPY src/ /opt/react-json-schema/src
1616
COPY .babelrc /opt/react-json-schema/.babelrc
17-
COPY generator/ /opt/react-json-schema/generator
17+
COPY scripts/generator/ /opt/react-json-schema/scripts/generator
1818
COPY package.json /opt/react-json-schema/package.json
1919
COPY package-lock.json /opt/react-json-schema/package-lock.json
2020
COPY index.js /opt/react-json-schema/index.js
@@ -39,7 +39,7 @@ RUN npm link webpack && \
3939
npm link @babel/preset-typescript && \
4040
npm link @babel/register && \
4141
npm link @babel/runtime
42-
RUN node generator/index.js
42+
RUN node scripts/generator/index.js
4343
RUN npx webpack
4444
# EXPOSE 3000
4545

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### [WIP] 3.0.0
22
##### Follow [Releases](https://github.com/vip-git/react-jsonschema-form-material-ui/releases) to get detailed overview
33
- Strict support for JSONSchema-Draft-7 including validations using [Ajv](https://github.com/ajv-validator/ajv#ajv-json-schema-validator)
4+
- Complete rewrite of v2 using `Typescript`
45
- Build system now upgraded to `Webpack 5`
56
- Support for `Material UI 5`
67
- Support for `React 17` and `NextJS 10`

0 commit comments

Comments
 (0)