Skip to content

Commit

Permalink
add some testing (adoptium#403)
Browse files Browse the repository at this point in the history
* add some testing

* linter fixes

* fix babel/preset-react
  • Loading branch information
gdams authored Apr 19, 2022
1 parent 24c2630 commit feac06c
Show file tree
Hide file tree
Showing 20 changed files with 5,200 additions and 19 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Linter

on:
pull_request:
branches: [ main ]

jobs:
ci:
name: Run CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
- run: npm install
- run: npm test
6 changes: 6 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": [
[ "@babel/preset-env", { "targets": { "node": true } } ],
[ "@babel/preset-react" ]
]
}
5 changes: 5 additions & 0 deletions jest-preprocess.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const babelOptions = {
presets: ['babel-preset-gatsby', '@babel/preset-typescript']
}

module.exports = require('babel-jest').default.createTransformer(babelOptions)
23 changes: 23 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
transform: {
'^.+\\.[jt]sx?$': '<rootDir>/jest-preprocess.js'
},
moduleNameMapper: {
'.+\\.(css|styl|less|sass|scss)$': 'identity-obj-proxy',
'.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/file-mock.js',
'^gatsby-page-utils/(.*)$': 'gatsby-page-utils/dist/$1', // Workaround for https://github.com/facebook/jest/issues/9771
'^gatsby-core-utils/(.*)$': 'gatsby-core-utils/dist/$1', // Workaround for https://github.com/facebook/jest/issues/9771
'^gatsby-plugin-utils/(.*)$': [
'gatsby-plugin-utils/dist/$1',
'gatsby-plugin-utils/$1'
] // Workaround for https://github.com/facebook/jest/issues/9771
},
testPathIgnorePatterns: ['node_modules', '\\.cache', '<rootDir>.*/public'],
transformIgnorePatterns: ['node_modules/(?!(gatsby)/)'],
globals: {
__PATH_PREFIX__: ''
},
testURL: 'http://localhost',
setupFiles: ['<rootDir>/loadershim.js'],
testEnvironment: 'jest-environment-jsdom'
}
3 changes: 3 additions & 0 deletions loadershim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
global.___loader = {
enqueue: jest.fn()
}
Loading

0 comments on commit feac06c

Please sign in to comment.