Skip to content

Commit 2f8026b

Browse files
authored
[patch] fix for describe.only and describe.skip (#89)
1 parent 59aff43 commit 2f8026b

File tree

7 files changed

+141
-15
lines changed

7 files changed

+141
-15
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
## Change Log
2+
### 0.16.1
3+
- [patch] fixes for isse #88 - fixed describe.only and describe.skip
4+
25
### 0.16.0
36
- [minor] setting to attach screenshots to a steps by options to cy.screeshot command
7+
48
### 0.15.3
59
- [patch] fix moving test attachments during execution for test
10+
611
### 0.15.2
712
- [patch] minor packages updates
13+
814
### 0.15.1
915
- [patch] fix of corner case with custom commands in #75
1016

integration/e2e/skip/skip-suite.cy.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
describe.skip('skipped', () => {
2+
beforeEach(() => {
3+
cy.log('before each for skipped');
4+
});
5+
6+
it('test', function () {
7+
cy.log('skipped');
8+
});
9+
10+
afterEach(() => {
11+
cy.log('after each for skipped');
12+
});
13+
});

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"webpack": "^5.89.0"
119119
},
120120
"dependencies": {
121-
"@mmisty/cypress-tags": "^1.0.14",
121+
"@mmisty/cypress-tags": "^1.0.15",
122122
"allure-js-commons": "^2.9.2",
123123
"allure-js-parser": "^0.0.7",
124124
"debug": "^4.3.4",

src/setup/setup-gherkin.ts

+16-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { parseInlineTags } from '@mmisty/cypress-tags/utils/tags';
33

44
export const addGherkin = () => {
55
const originalDesc = describe;
6+
const originalDescSkip = describe.skip;
7+
const originalDescOnly = describe.only;
68

79
const getTags = (test: any): { tag: string; info: string }[] => {
810
// this is tags support for @badeball/cypress-cucumber-preprocessor
@@ -18,15 +20,22 @@ export const addGherkin = () => {
1820

1921
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2022
// @ts-ignore
21-
(global as any).describe = function (...args) {
23+
const parseTags = original =>
2224
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2325
// @ts-ignore
24-
const suite: Suite = originalDesc(...args);
26+
function (...args) {
27+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
28+
// @ts-ignore
29+
const suite: Suite = original(...args);
2530

26-
suite.eachTest((test: any) => {
27-
test.tags = getTags(test);
28-
});
31+
suite.eachTest((test: any) => {
32+
test.tags = getTags(test);
33+
});
2934

30-
return suite;
31-
};
35+
return suite;
36+
};
37+
38+
(global as any).describe = parseTags(originalDesc);
39+
(global as any).describe.skip = parseTags(originalDescSkip);
40+
(global as any).describe.only = parseTags(originalDescOnly);
3241
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { createResTest2, fixResult } from '../../../cy-helper/utils';
2+
import { parseAllure } from 'allure-js-parser';
3+
4+
describe('several tests run by describe.only', () => {
5+
const res = createResTest2(
6+
[
7+
`
8+
describe.only('hello suite', () => {
9+
it('hello test 1', () => {
10+
cy.log('message');
11+
});
12+
13+
it('hello test 2', () => {
14+
cy.log('message');
15+
});
16+
17+
it('hello test 3', () => {
18+
cy.log('message');
19+
});
20+
21+
it('hello test 4', () => {
22+
cy.log('message');
23+
});
24+
});
25+
`,
26+
],
27+
{ allureAddVideoOnPass: 'true' },
28+
);
29+
30+
describe('check results', () => {
31+
let resFixed;
32+
33+
beforeAll(() => {
34+
const results = parseAllure(res.watch);
35+
resFixed = fixResult(results);
36+
});
37+
38+
it('check tests count', async () => {
39+
expect(resFixed.length).toEqual(4);
40+
});
41+
42+
it('check results', async () => {
43+
expect((res.result.res as any)?.totalSkipped).toEqual(0);
44+
expect((res.result.res as any)?.totalPending).toEqual(0);
45+
expect((res.result.res as any)?.totalPassed).toEqual(4);
46+
expect((res.result.res as any)?.totalFailed).toEqual(0);
47+
});
48+
});
49+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { createResTest2, fixResult } from '../../../cy-helper/utils';
2+
import { parseAllure } from 'allure-js-parser';
3+
4+
describe('several tests skipped by describe.skip', () => {
5+
const res = createResTest2(
6+
[
7+
`
8+
describe.skip('hello suite', () => {
9+
it('hello test 1', () => {
10+
cy.log('message');
11+
});
12+
13+
it('hello test 2', () => {
14+
cy.log('message');
15+
});
16+
17+
it('hello test 3', () => {
18+
cy.log('message');
19+
});
20+
21+
it('hello test 4', () => {
22+
cy.log('message');
23+
});
24+
});
25+
`,
26+
],
27+
{ allureAddVideoOnPass: 'true' },
28+
);
29+
30+
describe('check results', () => {
31+
let resFixed;
32+
33+
beforeAll(() => {
34+
const results = parseAllure(res.watch);
35+
resFixed = fixResult(results);
36+
});
37+
38+
it('check tests count', async () => {
39+
expect(resFixed.length).toEqual(4);
40+
});
41+
42+
it('check results', async () => {
43+
expect((res.result.res as any)?.totalFailed).toEqual(0);
44+
expect((res.result.res as any)?.totalPassed).toEqual(0);
45+
expect((res.result.res as any)?.totalSkipped).toEqual(0);
46+
expect((res.result.res as any)?.totalPending).toEqual(4);
47+
});
48+
});
49+
});

0 commit comments

Comments
 (0)