@mmisty/cypress-tags
TypeScript icon, indicating that this package has built-in type declarations

1.0.17 • Public • Published

Cypress-tags

This plugin helps to parse tags to add them into Mocha Test object, so you can access tags within hooks and within a test.

Example:

    it('test with tags @test', { tags: ['@abc'] }, function () {
      // this.test?.tags object has all tags
      expect(this.test?.tags).to.deep.eq([
        { tag: '@abc', info: [] },
        { tag: '@test', info: [] },
      ]);
    });

Installation / setup

  1. install with npm:

    npm i -D @mmisty/cypress-tags

    or with yarn:

    yarn add @mmisty/cypress-tags -D
  2. configure project:

    Put into your support.ts (or e2e.ts) file

    import '@mmisty/cypress-tags'
  3. That's it! Types should be added automatically if you use typescript.

Adding tags

There are several ways to add tags:

  1. inline tags - just add them into test or suite title (ex @simple, @tag("info"))
it('test with tags @simple @tag("withInfo")', function () { 
   // ...
});
  1. cypress configuration object:
it('test with tags', { tags: ['@abc'] }, function () { 
   // ...
});
  1. cypress configuration object may also have a string type and also parsed tag type:
it('test with tags', { tags: '@abc' }, function () {
   // ...
});
it('test with tags', { tags: [{ tag: '@abc', info: ['my info'] }] }, function () {
   // ...
});

Using tags

When tags are added to a test you can use them within hooks. This may be helpful when you want to do some action depending on tags:

Example (will skip tests with @skip tag):

// my.test.ts
it('test to skip @skip', function () {
   // ...
});

// e2e.ts / setup.ts
beforeEach(function() {
  const test = this.currentTest;
  if(test){
    if(test.tags?.map(t => t.tag).includes('@skip')){
      this.skip();
    }
  }
})

Env

To see tags in test / suite title set env variable cyTagsShowTagsInTitle to true

If you want to keep titles as they are set variable to undefined

  • [ ] todo: when var is true show only own tags

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.1713,875latest
1.0.16-alpha.40alpha

Version History

VersionDownloads (Last 7 Days)Published
1.0.1713,875
1.0.16-alpha.40
1.0.16-alpha.30
1.0.16-alpha.20
1.0.16-alpha.10
1.0.165,437
1.0.16-alpha.00
1.0.153,272
1.0.15-alpha.00
1.0.14344
1.0.130
1.0.120
1.0.110
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.21
1.0.10

Package Sidebar

Install

npm i @mmisty/cypress-tags

Weekly Downloads

18,052

Version

1.0.17

License

Apache-2.0

Unpacked Size

18 kB

Total Files

17

Last publish

Collaborators

  • mmisty