Skip to content

Commit

Permalink
feat(project): add jest-config-carbon (carbon-design-system#7315)
Browse files Browse the repository at this point in the history
* feat(project): add jest-config-carbon

* chore(project): update yarn.lock

* chore(format): run prettier

Co-authored-by: Josh Black <[email protected]>
Co-authored-by: TJ Egan <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Nov 20, 2020
1 parent 80d1abd commit 122338a
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 64 deletions.
1 change: 1 addition & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**/examples/**
**/vendor/**
**/_inlined/**
**/coverage/**

# Generated SCSS directories and files
**/packages/colors/**/*.scss
Expand Down
4 changes: 4 additions & 0 deletions config/jest-config-carbon/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/__mocks__/**
**/__tests__/**
**/examples/**
**/tasks/**
29 changes: 29 additions & 0 deletions config/jest-config-carbon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# jest-config-carbon

> Jest configuration and preset for Carbon
## Getting started

To install `jest-config-carbon` in your project, you will need to run the
following command using [npm](https://www.npmjs.com/):

```bash
npm install -S jest-config-carbon
```

If you prefer [Yarn](https://yarnpkg.com/en/), use the following command
instead:

```bash
yarn add jest-config-carbon
```

## 🙌 Contributing

We're always looking for contributors to help us fix bugs, build new features,
or help us improve the project documentation. If you're interested, definitely
check out our [Contributing Guide](/.github/CONTRIBUTING.md)! 👀

## 📝 License

Licensed under the [Apache 2.0 License](/LICENSE).
49 changes: 49 additions & 0 deletions config/jest-config-carbon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright IBM Corp. 2018, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = {
moduleFileExtensions: ['js', 'json', 'node'],
reporters: ['default'],
setupFiles: [require.resolve('./setup/setup.js')],
setupFilesAfterEnv: [require.resolve('./setup/setupAfterEnv.js')],
snapshotSerializers: ['enzyme-to-json/serializer'],
testMatch: [
'<rootDir>/**/__tests__/**/*.js?(x)',
'<rootDir>/**/*.(spec|test).js?(x)',
'<rootDir>/**/*-(spec|test).js?(x)',
],
transform: {
'^.+\\.(js|jsx)$': require.resolve('./transform/jsTransform.js'),
'^.+\\.css$': require.resolve('./transform/cssTransform.js'),
'^(?!.*\\.(js|jsx|css|json)$)': require.resolve(
'./transform/fileTransform.js'
),
},
testRunner: 'jest-circus/runner',
testPathIgnorePatterns: [
'/cjs/',
'/dist/',
'/es/',
'/lib/',
'/build/',
'e2e',
'examples',
'/umd/',
],
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
watchPathIgnorePatterns: [
'/cjs/',
'/dist/',
'/es/',
'/examples/',
'/lib/',
'/storybook/',
'/results/',
],
};
12 changes: 12 additions & 0 deletions config/jest-config-carbon/jest-preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright IBM Corp. 2018, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

const config = require('./');

module.exports = config;
File renamed without changes.
40 changes: 40 additions & 0 deletions config/jest-config-carbon/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "jest-config-carbon",
"private": true,
"description": "Jest configuration and preset for Carbon",
"dependencies": {
"@babel/core": "^7.10.0",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-proposal-export-default-from": "^7.7.4",
"@babel/plugin-proposal-export-namespace-from": "^7.7.4",
"@babel/plugin-transform-runtime": "^7.10.0",
"@babel/preset-env": "^7.10.0",
"@babel/preset-react": "^7.10.0",
"@babel/runtime": "^7.10.0",
"@ibma/aat": "https://able.ibm.com/tools/dist/ibma-aat-2.0.6.tgz",
"accessibility-checker": "^3.1.1",
"axe-core": "^3.3.2",
"babel-jest": "^26.0.1",
"chalk": "^4.1.0",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"enzyme-to-json": "^3.3.5",
"jest-circus": "^26.0.1"
},
"version": "0.0.0",
"license": "Apache-2.0",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/carbon-design-system/carbon.git",
"directory": "config/jest-config-carbon"
},
"bugs": "https://github.com/carbon-design-system/carbon/issues",
"keywords": [
"ibm",
"carbon",
"carbon-design-system",
"components",
"react"
]
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

const chalk = require('chalk');
const util = require('util');
const toHaveNoAxeViolations = require('./matchers/toHaveNoAxeViolations');
const toHaveNoDAPViolations = require('./matchers/toHaveNoDAPViolations');
const toHaveNoACViolations = require('./matchers/toHaveNoACViolations');
const toHaveNoAxeViolations = require('../matchers/toHaveNoAxeViolations');
const toHaveNoDAPViolations = require('../matchers/toHaveNoDAPViolations');
const toHaveNoACViolations = require('../matchers/toHaveNoACViolations');

// We can extend `expect` using custom matchers as defined by:
// https://jest-bot.github.io/jest/docs/expect.html#expectextendmatchers
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
59 changes: 2 additions & 57 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,19 @@
"@babel/runtime": "^7.10.0",
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@ibma/aat": "https://able.ibm.com/tools/dist/ibma-aat-2.0.6.tgz",
"@testing-library/dom": "^7.26.6",
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/react": "^11.1.1",
"@testing-library/user-event": "^12.2.0",
"accessibility-checker": "^3.1.1",
"all-contributors-cli": "^6.19.0",
"axe-core": "^3.3.2",
"babel-jest": "^26.0.1",
"cross-env": "^5.2.0",
"cross-spawn": "^6.0.5",
"doctoc": "^1.4.0",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"enzyme-to-json": "^3.3.5",
"eslint": "^6.8.0",
"fs-extra": "^8.1.0",
"glob": "^7.1.4",
"husky": "^4.0.10",
"jest": "^26.0.1",
"jest-circus": "^26.0.1",
"jest-junit": "^10.0.0",
"lerna": "^3.20.2",
"lint-staged": "^9.5.0",
Expand Down Expand Up @@ -148,63 +140,16 @@
]
},
"jest": {
"preset": "jest-config-carbon",
"collectCoverageFrom": [
"packages/**/src/**/*.js",
"!packages/{bundler,cli,components,sketch}/**",
"!packages/**/{examples,stories}/**",
"!**/*-story.js"
],
"moduleFileExtensions": [
"js",
"json",
"node"
],
"reporters": [
"default",
"jest-junit"
],
"setupFiles": [
"./tasks/jest/setup.js"
],
"setupFilesAfterEnv": [
"./tasks/jest/setupAfterEnv.js"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"testMatch": [
"<rootDir>/**/__tests__/**/*.js?(x)",
"<rootDir>/**/*.(spec|test).js?(x)",
"<rootDir>/**/*-(spec|test).js?(x)"
],
"transform": {
"^.+\\.(js|jsx)$": "./tasks/jest/jsTransform.js",
"^.+\\.css$": "./tasks/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|css|json)$)": "./tasks/jest/fileTransform.js"
},
"testRunner": "jest-circus/runner",
"testPathIgnorePatterns": [
"/cjs/",
"/dist/",
"/es/",
"/lib/",
"/build/",
"e2e",
"examples",
"/umd/"
],
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
],
"watchPathIgnorePatterns": [
"/cjs/",
"/dist/",
"/es/",
"/examples/",
"/lib/",
"/storybook/",
"/results/"
]
},
"dependencies": {}
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20740,7 +20740,7 @@ react-docgen@^5.0.0:

react-dom@^16.6.0, react-dom@^16.8.3, react-dom@^16.8.6, react-dom@^16.9.0, react-dom@~16.9.0:
version "16.9.0"
resolved "https://registry.npmjs.org/react-dom/-/react-dom-16.9.0.tgz#5e65527a5e26f22ae3701131bcccaee9fb0d3962"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.9.0.tgz#5e65527a5e26f22ae3701131bcccaee9fb0d3962"
integrity sha512-YFT2rxO9hM70ewk9jq0y6sQk8cL02xm4+IzYBz75CQGlClQQ1Bxq0nhHF6OtSbit+AIahujJgb/CPRibFkMNJQ==
dependencies:
loose-envify "^1.1.0"
Expand Down Expand Up @@ -20828,7 +20828,7 @@ react-inspector@^4.0.0:

react-is@^16.12.0, react-is@^16.13.1, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.2, react-is@^16.8.4, react-is@^16.8.6, react-is@^16.9.0, react-is@^17.0.1, react-is@~16.9.0:
version "16.9.0"
resolved "https://registry.npmjs.org/react-is/-/react-is-16.9.0.tgz#21ca9561399aad0ff1a7701c01683e8ca981edcb"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.9.0.tgz#21ca9561399aad0ff1a7701c01683e8ca981edcb"
integrity sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw==

react-lifecycles-compat@^3.0.4:
Expand Down Expand Up @@ -20894,7 +20894,7 @@ react-syntax-highlighter@^11.0.2:

react-test-renderer@^16.0.0-0, react-test-renderer@^16.8.6, react-test-renderer@~16.9.0:
version "16.9.0"
resolved "https://registry.npmjs.org/react-test-renderer/-/react-test-renderer-16.9.0.tgz#7ed657a374af47af88f66f33a3ef99c9610c8ae9"
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.9.0.tgz#7ed657a374af47af88f66f33a3ef99c9610c8ae9"
integrity sha512-R62stB73qZyhrJo7wmCW9jgl/07ai+YzvouvCXIJLBkRlRqLx4j9RqcLEAfNfU3OxTGucqR2Whmn3/Aad6L3hQ==
dependencies:
object-assign "^4.1.1"
Expand Down Expand Up @@ -20922,7 +20922,7 @@ react-transition-group@^2.2.1:

react@^16.6.0, react@^16.8.3, react@^16.8.6, react@^16.9.0, react@~16.9.0:
version "16.9.0"
resolved "https://registry.npmjs.org/react/-/react-16.9.0.tgz#40ba2f9af13bc1a38d75dbf2f4359a5185c4f7aa"
resolved "https://registry.yarnpkg.com/react/-/react-16.9.0.tgz#40ba2f9af13bc1a38d75dbf2f4359a5185c4f7aa"
integrity sha512-+7LQnFBwkiw+BobzOF6N//BdoNw0ouwmSJTEm9cglOOmsg/TMiFHZLe2sEoN5M7LgJTj9oHH0gxklfnQe66S1w==
dependencies:
loose-envify "^1.1.0"
Expand Down

0 comments on commit 122338a

Please sign in to comment.