Skip to content

Commit 0bc8dbe

Browse files
authored
Merge pull request #7 from user-interviews/feature/UIDS-6-setup-testing
UIDS-6 install latest version of Storybook and setup Jest
2 parents 971797c + 4652010 commit 0bc8dbe

File tree

13 files changed

+3542
-898
lines changed

13 files changed

+3542
-898
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
jest.config.js
2+
lib
3+
node_modules

.eslintrc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
"extends": "airbnb",
33
"overrides": [
44
{
5-
"files": "config/**/*.js",
6-
"env": {
7-
"node": true
8-
},
9-
"parserOptions": {
10-
"ecmaVersion": 2018
5+
"files": [
6+
"stories/*.{js,jsx}"
7+
],
8+
rules: {
9+
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
1110
},
12-
"rules": {
13-
"global-require": 0
14-
}
1511
},
1612
{
1713
"files": [

.storybook/addons.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

.storybook/config.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

.storybook/main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
addons: [
3+
'@storybook/addon-a11y/register',
4+
'@storybook/addon-actions/register',
5+
'@storybook/addon-docs',
6+
'@storybook/addon-knobs/register',
7+
'@storybook/addon-links/register',
8+
'@storybook/addon-storysource/register'
9+
],
10+
stories: ['../stories/*.stories.js[x]'],
11+
};

.storybook/presets.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

jest.config.js

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
// For a detailed explanation regarding each configuration property, visit:
2+
// https://jestjs.io/docs/en/configuration.html
3+
4+
module.exports = {
5+
// All imported modules in your tests should be mocked automatically
6+
// automock: false,
7+
8+
// Stop running tests after `n` failures
9+
// bail: 0,
10+
11+
// Respect "browser" field in package.json when resolving modules
12+
// browser: false,
13+
14+
// The directory where Jest should store its cached dependency information
15+
// cacheDirectory: "/private/var/folders/hp/r9c9kxr55rgd1r4zbdmktlj00000gn/T/jest_dx",
16+
17+
// Automatically clear mock calls and instances between every test
18+
clearMocks: true,
19+
20+
// Indicates whether the coverage information should be collected while executing the test
21+
collectCoverage: true,
22+
23+
// An array of glob patterns indicating a set of files for which coverage information should be collected
24+
// collectCoverageFrom: null,
25+
26+
// The directory where Jest should output its coverage files
27+
coverageDirectory: "coverage",
28+
29+
// An array of regexp pattern strings used to skip coverage collection
30+
coveragePathIgnorePatterns: [
31+
"/node_modules/"
32+
],
33+
34+
// A list of reporter names that Jest uses when writing coverage reports
35+
coverageReporters: [
36+
"text",
37+
],
38+
39+
// An object that configures minimum threshold enforcement for coverage results
40+
// coverageThreshold: null,
41+
42+
// A path to a custom dependency extractor
43+
// dependencyExtractor: null,
44+
45+
// Make calling deprecated APIs throw helpful error messages
46+
// errorOnDeprecated: false,
47+
48+
// Force coverage collection from ignored files using an array of glob patterns
49+
// forceCoverageMatch: [],
50+
51+
// A path to a module which exports an async function that is triggered once before all test suites
52+
// globalSetup: null,
53+
54+
// A path to a module which exports an async function that is triggered once after all test suites
55+
// globalTeardown: null,
56+
57+
// A set of global variables that need to be available in all test environments
58+
// globals: {},
59+
60+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
61+
// maxWorkers: "50%",
62+
63+
// An array of directory names to be searched recursively up from the requiring module's location
64+
// moduleDirectories: [
65+
// "node_modules"
66+
// ],
67+
68+
// An array of file extensions your modules use
69+
// moduleFileExtensions: [
70+
// "js",
71+
// "json",
72+
// "jsx",
73+
// "ts",
74+
// "tsx",
75+
// "node"
76+
// ],
77+
78+
// A map from regular expressions to module names that allow to stub out resources with a single module
79+
moduleNameMapper: {
80+
'\\.(css|less|scss)$': '<rootDir>/spec/__mocks__/styleMock.js',
81+
},
82+
83+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
84+
// modulePathIgnorePatterns: [],
85+
86+
// Activates notifications for test results
87+
// notify: false,
88+
89+
// An enum that specifies notification mode. Requires { notify: true }
90+
// notifyMode: "failure-change",
91+
92+
// A preset that is used as a base for Jest's configuration
93+
// preset: null,
94+
95+
// Run tests from one or more projects
96+
// projects: null,
97+
98+
// Use this configuration option to add custom reporters to Jest
99+
// reporters: undefined,
100+
101+
// Automatically reset mock state between every test
102+
// resetMocks: false,
103+
104+
// Reset the module registry before running each individual test
105+
// resetModules: false,
106+
107+
// A path to a custom resolver
108+
// resolver: null,
109+
110+
// Automatically restore mock state between every test
111+
// restoreMocks: false,
112+
113+
// The root directory that Jest should scan for tests and modules within
114+
// rootDir: null,
115+
116+
// A list of paths to directories that Jest should use to search for files in
117+
roots: [
118+
"spec"
119+
],
120+
121+
// Allows you to use a custom runner instead of Jest's default test runner
122+
// runner: "jest-runner",
123+
124+
// The paths to modules that run some code to configure or set up the testing environment before each test
125+
// setupFiles: [],
126+
127+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
128+
// setupFilesAfterEnv: [],
129+
130+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
131+
// snapshotSerializers: [],
132+
133+
// The test environment that will be used for testing
134+
// testEnvironment: "jest-environment-jsdom",
135+
136+
// Options that will be passed to the testEnvironment
137+
// testEnvironmentOptions: {},
138+
139+
// Adds a location field to test results
140+
// testLocationInResults: false,
141+
142+
// The glob patterns Jest uses to detect test files
143+
testMatch: [
144+
"**/?(*.)+(spec|test).[tj]s?(x)"
145+
],
146+
147+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
148+
// testPathIgnorePatterns: [
149+
// "/node_modules/"
150+
// ],
151+
152+
// The regexp pattern or array of patterns that Jest uses to detect test files
153+
// testRegex: [],
154+
155+
// This option allows the use of a custom results processor
156+
// testResultsProcessor: null,
157+
158+
// This option allows use of a custom test runner
159+
// testRunner: "jasmine2",
160+
161+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
162+
// testURL: "http://localhost",
163+
164+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
165+
// timers: "real",
166+
167+
// A map from regular expressions to paths to transformers
168+
// transform: null,
169+
170+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
171+
// transformIgnorePatterns: [
172+
// "/node_modules/"
173+
// ],
174+
175+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
176+
// unmockedModulePathPatterns: undefined,
177+
178+
// Indicates whether each individual test should be reported during the run
179+
// verbose: null,
180+
181+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
182+
// watchPathIgnorePatterns: [],
183+
184+
// Whether to use watchman for file crawling
185+
// watchman: true,
186+
};

package.json

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"build-storybook": "build-storybook -s public",
1818
"build-storybook-docs": "build-storybook -s public --docs",
1919
"deploy-storybook": "storybook-to-ghpages",
20-
"prepare": "yarn build"
20+
"prepare": "yarn build",
21+
"test": "jest"
2122
},
2223
"eslintConfig": {
2324
"extends": "react-app"
@@ -38,24 +39,32 @@
3839
"@babel/cli": "^7.8.4",
3940
"@babel/core": "^7.8.4",
4041
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
41-
"@storybook/addon-a11y": "^5.2.6",
42-
"@storybook/addon-actions": "^5.2.6",
43-
"@storybook/addon-docs": "^5.2.6",
44-
"@storybook/addon-knobs": "^5.2.6",
45-
"@storybook/addon-links": "^5.2.6",
46-
"@storybook/addon-storysource": "^5.2.6",
47-
"@storybook/addons": "^5.2.6",
48-
"@storybook/react": "^5.2.6",
42+
"@storybook/addon-a11y": "^5.3.13",
43+
"@storybook/addon-actions": "^5.3.13",
44+
"@storybook/addon-docs": "^5.3.13",
45+
"@storybook/addon-jest": "^5.3.13",
46+
"@storybook/addon-knobs": "^5.3.13",
47+
"@storybook/addon-links": "^5.3.13",
48+
"@storybook/addon-storyshots": "^5.3.13",
49+
"@storybook/addon-storysource": "^5.3.13",
50+
"@storybook/addons": "^5.3.13",
51+
"@storybook/react": "^5.3.13",
4952
"@storybook/storybook-deployer": "^2.8.1",
53+
"babel-eslint": "^10.0.3",
5054
"babel-loader": "^8.0.6",
5155
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
5256
"babel-preset-env": "^1.7.0",
5357
"babel-preset-react": "^6.24.1",
5458
"css-loader": "^3.4.2",
59+
"eslint": "^6.8.0",
5560
"eslint-config-airbnb": "^18.0.1",
5661
"eslint-import-resolver-webpack": "^0.11.1",
5762
"eslint-plugin-babel": "^5.3.0",
63+
"eslint-plugin-import": "^2.20.1",
64+
"eslint-plugin-jsx-a11y": "^6.2.3",
65+
"eslint-plugin-react": "^7.18.3",
5866
"eslint-utils": "^1.4.3",
67+
"react-test-renderer": "^16.12.0",
5968
"sass-loader": "^8.0.2",
6069
"style-loader": "^1.1.3"
6170
},

spec/Storyshots.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import initStoryshots from '@storybook/addon-storyshots';
2+
3+
initStoryshots();

spec/__mocks__/styleMock.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {};

0 commit comments

Comments
 (0)