Skip to content

Commit

Permalink
snapshots test
Browse files Browse the repository at this point in the history
  • Loading branch information
dangreen committed Sep 6, 2019
1 parent 2fd7521 commit e819064
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"transformDynamicImport": true
}
]
],
"plugins": [
"require-context-hook"
]
}
}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ node_modules
lib
package
build
storybook-build

.env
16 changes: 6 additions & 10 deletions .storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import React from 'react';
import {
configure
} from '@trigen/scripts-preset-react-app/storybook/config';
import {
addDecorator
} from '@storybook/react';
import '@flexis/ui/reboot.st.css';

addDecorator(story => (
<div>
{story()}
</div>
));
const stories = require.context(
process.env.PROJECT_SRC,
true,
/\.stories\.tsx$/
);

configure(module);
configure(module, stories);
6 changes: 5 additions & 1 deletion jest.config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"testRegex": "/src/App/.*(\\.|/)spec\\.(jsx?|tsx?)$",
"setupFiles": [
"@trigen/scripts-plugin-storybook/jest/registerContext"
],
"testRegex": "/(src/App|test)/.*(\\.|/)spec\\.(jsx?|tsx?)$",
"transform": {
"^.+\\.(jsx?|tsx?)$": "babel-jest"
},
"moduleNameMapper": {
"\\.(css|svg)$": "@trigen/scripts-plugin-storybook/jest/mockFile",
"~(.*)$": "<rootDir>/src/App/$1"
},
"collectCoverage": true,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions test/storyshots.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import initStoryshots, {
getMatchOptions
} from '@trigen/scripts-plugin-storybook/jest/storyshots';

process.env.FLEXISUI_STORIES = JSON.stringify(true);

initStoryshots({
getMatchOptions(info) {

const options = getMatchOptions(info);
const failureThreshold = 0.2;

// switch (options.customSnapshotIdentifier) {

// case 'ScrollArea__with-table':
// failureThreshold = 5;
// break;

// case 'Table__with-rows':
// case 'Table__with-order':
// failureThreshold = 1;
// break;

// default:
// }

return {
failureThresholdType: 'percent',
failureThreshold,
...options
};
},
getScreenshotOptions() {
return {
fullPage: false
};
}
});
6 changes: 6 additions & 0 deletions test/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../tslint.json",
"rules": {
"no-magic-numbers": false
}
}

0 comments on commit e819064

Please sign in to comment.