0.8.1 • Published 24 days ago

creevey v0.8.1

Weekly downloads
779
License
MIT
Repository
github
Last release
24 days ago

creevey

Pretty easy visual testing with magic

Commitizen friendly

How to use

  • npm install -D creevey
  • Add withCreevey as top-level storybook decorator
  • Run tests yarn creevey --gridUrl "<gridUrl>/wd/hub"

What's storybook decorator?

Using Decorators

// .storybook/config.js
import { addDecorator } from '@storybook/react';
import { withCreevey } from 'creevey';

addDecorator(withCreevey({ captureElement: '#root' }));

/* ... */

Also you can define creevey.config.ts

import path from 'path';
import { CreeveyConfig } from 'creevey';

const config: CreeveyConfig = {
  gridUrl: '<gridUrl>/wd/hub',
  storybookUrl: 'http://localhost:6006',
  storybookDir: path.join(__dirname, '.storybook'),
  screenDir: path.join(__dirname, 'images'),
  reportDir: path.join(__dirname, 'report'),
  threshold: 0.1,
  maxRetries: 2,
  browsers: {
    chrome: true,
    ff: 'firefox',
    ie11: {
      browserName: 'internet explorer',
      gridUrl: '<anotherGridUrl>/wd/hub',
      limit: 2,
      /* capabilities */
    },
    otherChrome: {
      browserName: 'chrome',
      storybookUrl: 'http://mystoryhost:6007',
      viewport: { width: 1024, height: 720 },
    },
  },
};

export default config;

Creevey CLI options

  • --config — Specify path to config file. Default ./creevey.config
  • --reporter — Use another reporter for mocha instead of default spec
  • --gridUrl — Specify selenium grid url, work only in zero-config
  • --ui — Start web server
  • --update — Approve all images from report directory
  • --port — Specify port for web server. Default 3000
  • --reportDir — Path where reports will be stored
  • --screenDir — Path where reference images are located

withCreevey decorator parameters

You can specify storybook parameters for withCreevey decorator:

// Global parameters can be defined in storybook config
addDecorator(
  withCreevey({
    captureElement: '#root',
    tests: {
      /* see examples below */
    },
    skip: {
      /* see examples below */
    },
  }),
);
// For new `Component Story Format` (CSF) https://storybook.js.org/docs/formats/component-story-format/
// Kind-level parameters work for all stories inside
export default {
  title: 'Views',
  parameters: {
    creevey: {
      /* ... */
    },
  },
};

// Story-level parameters work only for that story
export const simple = () => <MyComponent />;
simple.story = {
  parameters: {
    creevey: {
      /* ... */
    },
  },
};
// For Old `StoriesOf` API (Storybook version < 5.2)
storiesOf('Views', module)
  .addParameters({
    creevey: {
      /* ... */
    },
  }) // Kind-level
  .add('simple', () => <MyComponent />, {
    creevey: {
      /* ... */
    },
  }); // Story-level

NOTE: Parameters for story will be deep-merged with parameters from higher levels.

tests option examples:

tests option is a plain object where key used as test name and value is a test function. Under the hood of creevey is used mocha+chai and for chai additionaly defined matchImage assertion.

import { expect } from 'chai';

export default { title: 'MyComponent' };

export const Simple = () => <MyComponent />;
Simple.story = {
  parameters: {
    creevey: {
      async click(this: { broser: WebDriver }) {
        const element = await this.browser.findElement({ css: '#root' });

        await this.browser
          .actions({ bridge: true })
          .click(element)
          .perform();

        await expect(await element.takeScreenshot()).to.matchImage('clicked component');
      },
    },
  },
};

skip option examples:

  • Skip all stories for all browsers:
    • skip: 'Skip reason message'
    • skip: { reason: 'Skip reason message' }
  • Skip all stories for specific browsers:
    • skip: { in: 'ie11' }
    • skip: { in: ['ie11', 'chrome'] }
    • skip: { in: /^fire.*/ }
  • Skip all stories in specific kinds:
    • skip: { kinds: 'Button' }
    • skip: { kinds: ['Button', 'Input'] }
    • skip: { kinds: /.*Modal$/ }
  • Skip specific stories for all browsers:
    • skip: { stories: 'simple' }
    • skip: { stories: ['simple', 'special'] }
    • skip: { stories: /.*large$/ }
  • Multiple skip options: skip: [{ /* ... */ }]

NOTE: If you try to skip stories by story name, the storybook name format will be used (For more info see storybook-export-vs-name-handling)

FAQ

Get error Cannot find module '/path/to/project/creevey.config' with CRA

CRA don't have @babel/register or ts-node in deps, that used to load TypeScript modules in runtime. So you need to install one of those packages explicitly

0.9.0-beta.10

24 days ago

0.8.2-fix-wait.2

28 days ago

0.8.2-fix-wait.1

29 days ago

0.8.2-fix-wait.0

29 days ago

0.9.0-beta.9

3 months ago

0.9.0-beta.8

3 months ago

0.9.0-beta.7

4 months ago

0.9.0-beta.6

4 months ago

0.8.1-sb7.3

4 months ago

0.8.1-sb7.4

4 months ago

0.8.1-sb7.0

4 months ago

0.8.1-sb7.1

4 months ago

0.8.1-sb7.2

4 months ago

0.8.1

11 months ago

0.8.1-beta.1

12 months ago

0.9.0-beta.3

1 year ago

0.9.0-beta.5

1 year ago

0.9.0-beta.4

1 year ago

0.8.1-beta.0

1 year ago

0.8.0

1 year ago

0.8.0-beta.1

1 year ago

0.9.0-beta.1

1 year ago

0.9.0-beta.2

1 year ago

0.9.0-beta.0

2 years ago

0.8.0-beta.0

2 years ago

0.7.39

2 years ago

0.7.38

3 years ago

0.7.37

3 years ago

0.7.36

3 years ago

0.7.35

3 years ago

0.7.33

3 years ago

0.7.34

3 years ago

0.7.32

3 years ago

0.7.31

3 years ago

0.7.30

3 years ago

0.7.23-1

3 years ago

0.7.29

3 years ago

0.7.28

3 years ago

0.7.27

3 years ago

0.7.26

3 years ago

0.7.25

3 years ago

0.7.24

3 years ago

0.2.4-3

3 years ago

0.7.22

3 years ago

0.7.23

3 years ago

0.7.21

3 years ago

0.7.20

3 years ago

0.7.19

3 years ago

0.7.18

3 years ago

0.7.17

3 years ago

0.7.16

3 years ago

0.7.15

3 years ago

0.7.14

3 years ago

0.7.13

3 years ago

0.7.12

3 years ago

0.7.11

3 years ago

0.7.10

3 years ago

0.7.9

3 years ago

0.7.8

3 years ago

0.7.7

3 years ago

0.7.6

3 years ago

0.7.5

3 years ago

0.7.4

3 years ago

0.7.3

3 years ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.7.0-beta.21

3 years ago

0.7.0-beta.20

3 years ago

0.7.0-beta.19

3 years ago

0.7.0-beta.18

3 years ago

0.7.0-beta.17

4 years ago

0.7.0-beta.16

4 years ago

0.7.0-beta.15

4 years ago

0.7.0-beta.14

4 years ago

0.7.0-beta.13

4 years ago

0.7.0-beta.12

4 years ago

0.7.0-beta.11

4 years ago

0.7.0-beta.10

4 years ago

0.7.0-beta.9

4 years ago

0.7.0-beta.8

4 years ago

0.7.0-beta.7

4 years ago

0.7.0-beta.6

4 years ago

0.7.0-beta.5

4 years ago

0.7.0-beta.4

4 years ago

0.7.0-beta.3

4 years ago

0.7.0-beta.2

4 years ago

0.7.0-beta.1

4 years ago

0.7.0-beta.0

4 years ago

0.6.4

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.6.0-beta.8

4 years ago

0.6.0-beta.7

4 years ago

0.6.0-beta.6

4 years ago

0.6.0-beta.4

4 years ago

0.6.0-beta.5

4 years ago

0.5.7

4 years ago

0.6.0-beta.3

4 years ago

0.6.0-beta.2

4 years ago

0.6.0-beta.1

4 years ago

0.6.0-beta.0

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.10

4 years ago

0.4.11

4 years ago

0.4.9

4 years ago

0.4.8

4 years ago

0.4.7

4 years ago

0.4.5

4 years ago

0.4.6

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.2.4-2

4 years ago

0.2.4-1

4 years ago

0.2.7

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.4

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.30

4 years ago

0.0.29

5 years ago

0.0.28

5 years ago

0.0.27

5 years ago

0.0.26

5 years ago

0.0.25

5 years ago

0.0.24

5 years ago

0.0.23

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago