Skip to content

Commit

Permalink
Updates from template repo - test fixes and PR check script
Browse files Browse the repository at this point in the history
  • Loading branch information
doubleedesign committed May 12, 2024
2 parents 50ca8bc + cb55071 commit 8475b4c
Show file tree
Hide file tree
Showing 14 changed files with 2,015 additions and 181 deletions.
10 changes: 6 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"presets": [
"@babel/preset-env",
["@babel/preset-react", {
"runtime": "automatic"
}],
["@babel/preset-env", { "targets": { "node": "current" } }],
["@babel/preset-react", { "runtime": "automatic" }],
"@babel/preset-typescript"
],
"plugins": [
"babel-plugin-styled-components",
"react-magnetic-di/babel-plugin"
]
}
18 changes: 17 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,21 @@
"warn",
{ "allowConstantExport": true }
]
}
},
"overrides": [
{
"files": ["*.style.ts"],
"rules": {
"indent": ["warn", "tab", {
"SwitchCase": 1,
"FunctionExpression": {
"parameters": 1,
"body": 1
},
"MemberExpression": 1,
"offsetTernaryExpressions": true
}]
}
}
]
}
31 changes: 31 additions & 0 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Pull Request Checks

on:
pull_request:
branches:
- main

jobs:
tests-and-file-checks:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install dependencies
run: npm install

- name: Linting
run: npm run lint

- name: Project structure
run: npm run lint:structure

- name: Unit tests
run: npm run test:unit
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
testEnvironment: 'jsdom',
transform: {
'^.+\\.[t|j]sx?$': 'babel-jest',
'^.+\\.(tsx?|jsx?)$': 'babel-jest',
},
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
};
1 change: 1 addition & 0 deletions jest.setup.js → jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import '@testing-library/jest-dom';

21 changes: 21 additions & 0 deletions jest.utils.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { DiProvider, injectable, Injectable } from 'react-magnetic-di';
import { ReactNode } from 'react';
import { render } from '@testing-library/react';
import { useRouteError } from 'react-router-dom';

const commonDeps: Injectable[] = [
injectable(useRouteError, () => {
return {
status: 418,
data: 'I\'m a teapot',
};
}),
];

export const renderWithDeps = (component: ReactNode) => {
return render(
<DiProvider use={commonDeps}>
{component}
</DiProvider>
);
};
Loading

0 comments on commit 8475b4c

Please sign in to comment.