Skip to content

Commit

Permalink
feat: configure random seed generator
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed May 13, 2021
1 parent ac6d2e0 commit ab14802
Show file tree
Hide file tree
Showing 86 changed files with 3,791 additions and 4,024 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
"name": "jest cc-cli",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"cwd": "${workspaceFolder}/plugins/cc-cli",
"args": ["data-template-import-existing"],
"args": ["cli-story-data"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
Expand Down
36 changes: 18 additions & 18 deletions core/instrument/test/jest-tests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,6 @@ describe('component-tests', () => {
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table', 'pagination', '0'],
fullName: 'Table pagination 0 snapshot',
status: 'passed',
title: 'snapshot',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table', 'pagination', '0'],
fullName: 'Table pagination 0 accessibility',
status: 'passed',
title: 'accessibility',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table', 'pagination', '1'],
fullName: 'Table pagination 1 snapshot',
Expand Down Expand Up @@ -237,6 +221,22 @@ describe('component-tests', () => {
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table', 'pagination', '5'],
fullName: 'Table pagination 5 snapshot',
status: 'passed',
title: 'snapshot',
numPassingAsserts: 0,
failureDetails: [],
},
{
ancestorTitles: ['Table', 'pagination', '5'],
fullName: 'Table pagination 5 accessibility',
status: 'passed',
title: 'accessibility',
numPassingAsserts: 0,
failureDetails: [],
},
],
},
],
Expand Down Expand Up @@ -392,9 +392,9 @@ describe('component-tests', () => {
},
branches: {
total: 24,
covered: 11,
covered: 10,
skipped: 0,
pct: 45.83,
pct: 41.67,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ beforeAll(async () => {
describe('react typescript component', () => {
it('testResults ', () => {
expect(results?.results[0].testResults[0]).toMatchObject({
ancestorTitles: ['Popover', 'overview', '0'],
fullName: 'Popover overview 0 snapshot',
ancestorTitles: ['Popover', 'overview', '1'],
fullName: 'Popover overview 1 snapshot',
status: 'passed',
title: 'snapshot',
});
Expand Down
2 changes: 1 addition & 1 deletion examples/stories/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"directory": "examples/stories"
},
"scripts": {
"test:create": "cc-cli -g doc -i VariantButton -c ./.config -w -d 5",
"test:create": "cc-cli -g doc -i VariantButton -c ./.config -w -d 5 -s 1122334455",
"test": "yarn jest"
},
"jest": {
Expand Down
49 changes: 22 additions & 27 deletions examples/stories/src/stories/VariantButton/VariantButton.data.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,42 @@
import { VariantButtonProps } from './VariantButton';
const data: Record<string, Record<string, VariantButtonProps>> = {
overview: {
'0': {
text: 'Mrs. Berta Runolfsdottir',
variant: 'disabled',
fontSize: 20,
icon: 'down-arrow',
iconSide: 'left',
iconSize: 'large',
padding: 'medium',
},
'1': {
text: 'Darrel Simonis',
variant: 'primary',
text: 'Cecelia Langosh',
variant: 'success',
fontSize: 16,
icon: 'none',
iconSide: 'left',
padding: 'large',
iconSize: 'medium',
},
'2': {
text: 'Drew Terry',
fontSize: 18,
icon: 'search',
iconSide: 'left',
text: 'Murl Green I',
variant: 'disabled',
fontSize: 26,
icon: 'down-arrow',
iconSize: 'large',
},
'3': {
text: 'Anahi McLaughlin',
fontSize: 14,
text: 'Lela McClure',
variant: 'error',
fontSize: 24,
icon: 'left-arrow',
iconSide: 'right',
padding: 'large',
},
'4': {
text: 'Ms. Jean Barrows',
variant: 'accent',
fontSize: 23,
icon: 'up-arrow',
iconSide: 'left',
iconSize: 'large',
padding: 'small',
},
'4': {
text: 'Megane Stehr',
'5': {
text: 'Tanya Sanford',
variant: 'error',
fontSize: 21,
fontSize: 19,
icon: 'up-arrow',
iconSide: 'left',
iconSize: 'large',
padding: 'medium',
},
},
};

export default data;

This file was deleted.

1 change: 1 addition & 0 deletions examples/stories/src/tutorial/testing/jest-snapshots.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ quick start: the following command will generate a test file in `tests/stories.t
| `--exclude`<br/>`-x` | array of test file names to exclude (only for doc/story formats)| string[] | |
| `--ally`<br/>`-y` | whether to include axe accessibility tests | boolean | `true` |
| `--data`<br/>`-d` | create a data-driven testinf file with x number of rows | number | `0` (disabled) |
| `--seed`<br/>`-s` | random generator seed when generating data | number | undefined (new data on each run) |

### Examples

Expand Down
3 changes: 2 additions & 1 deletion plugins/cc-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"lint": "yarn eslint . --ext mdx,ts,tsx",
"create-bundle": "ccc -c test/.config -d test/bundle",
"prepare": "yarn build",
"test:create": "cc-cli -g story -c ./test/.config -o test -w",
"test:create": "cc-cli -g story -c ./test/.config -o test -w -s 1122334455",
"test": "yarn jest -i"
},
"homepage": "https://github.com/ccontrols/component-controls",
Expand All @@ -51,6 +51,7 @@
"@component-controls/webpack-compile": "^3.11.4",
"@component-controls/webpack-configs": "^3.11.4",
"dot": "^1.1.3",
"fast-deep-equal": "^3.1.3",
"path": "^0.12.7"
},
"devDependencies": {
Expand Down
8 changes: 8 additions & 0 deletions plugins/cc-cli/src/cli/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,12 @@ export const jestCliArgs: ArgOptions = [
type: 'number',
},
},
{
name: 'seed',
options: {
alias: 's',
description: 'random generator seed when generating data',
type: 'number',
},
},
];
2 changes: 2 additions & 0 deletions plugins/cc-cli/src/cli/cli-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const cliStore = async (options: CliOptions): Promise<void> => {
exclude,
ally,
data,
seed,
} = options;
const test =
userTest || `component-controls.test.${format === 'ts' ? 'ts' : 'js'}`;
Expand All @@ -37,6 +38,7 @@ export const cliStore = async (options: CliOptions): Promise<void> => {
exclude,
ally,
data,
seed,
},
createStoreTemplate,
);
Expand Down
2 changes: 2 additions & 0 deletions plugins/cc-cli/src/cli/cli-story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const cliStory = async (
exclude,
ally,
data,
seed,
} = options;
let documents: string[] = [];
let configuration: BuildConfiguration | undefined;
Expand Down Expand Up @@ -84,6 +85,7 @@ export const cliStory = async (
storyPath: name,
ally,
data,
seed,
output: output
? output
: bundle
Expand Down
3 changes: 3 additions & 0 deletions plugins/cc-cli/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const run = async (): Promise<void> => {
exclude,
ally,
data,
seed,
} = parsedArgs;
switch (parsedArgs.generate) {
case 'store':
Expand All @@ -40,6 +41,7 @@ export const run = async (): Promise<void> => {
exclude,
ally,
data,
seed,
} as CliOptions);
case 'story':
case 'doc':
Expand All @@ -57,6 +59,7 @@ export const run = async (): Promise<void> => {
exclude,
ally,
data,
seed,
} as CliOptions,
parsedArgs.generate === 'doc',
);
Expand Down
Loading

0 comments on commit ab14802

Please sign in to comment.