test: remove duplicated test(fail.only)
This commit is contained in:
parent
a0f72bfeaf
commit
ea033dbb3e
|
|
@ -920,112 +920,3 @@ test('afterAll should be run for test.skip', async ({ runInlineTest }) => {
|
|||
'afterAll2',
|
||||
]);
|
||||
});
|
||||
|
||||
test('should respect test.fail.only in beforeEach failure', async ({ runInlineTest }) => {
|
||||
const report = await runInlineTest({
|
||||
'a.test.js': `
|
||||
import { test, expect } from '@playwright/test';
|
||||
test.beforeEach(async ({}) => {
|
||||
console.log('beforeEach1');
|
||||
});
|
||||
test.beforeEach(async ({}) => {
|
||||
console.log('beforeEach2');
|
||||
throw new Error('beforeEach2');
|
||||
});
|
||||
test.afterEach(async ({}) => {
|
||||
console.log('afterEach');
|
||||
});
|
||||
test.fail.only('one', async ({}) => {
|
||||
console.log('test');
|
||||
});
|
||||
test('two', async ({}) => {
|
||||
console.log('test two');
|
||||
});
|
||||
`,
|
||||
});
|
||||
expect(report.output).toContain('beforeEach1\nbeforeEach2\nafterEach');
|
||||
expect(report.results[0].error.message).toContain('beforeEach2');
|
||||
expect(report.passed).toBe(1);
|
||||
expect(report.failed).toBe(0);
|
||||
});
|
||||
|
||||
test('should respect test.fail.only in afterAll exception', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
import { test, expect } from '@playwright/test';
|
||||
test.afterAll(() => {
|
||||
throw new Error('From the afterAll');
|
||||
});
|
||||
test.fail.only('passed', () => {
|
||||
console.log('test body');
|
||||
});
|
||||
test('skipped', () => {
|
||||
console.log('should not run');
|
||||
});
|
||||
`,
|
||||
});
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.passed).toBe(1);
|
||||
expect(result.failed).toBe(0);
|
||||
expect(result.output).toContain('test body');
|
||||
expect(result.output).not.toContain('should not run');
|
||||
});
|
||||
|
||||
|
||||
test('should run beforeAll and afterAll hooks with test.fail.only', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'hooks-fail-only.spec.ts': `
|
||||
import { test, expect } from '@playwright/test';
|
||||
test.beforeAll(() => {
|
||||
console.log('\\n%%beforeAll');
|
||||
});
|
||||
test.afterAll(() => {
|
||||
console.log('\\n%%afterAll');
|
||||
});
|
||||
test.fail.only('failing test', () => {
|
||||
console.log('\\n%%test body');
|
||||
expect(1).toBe(2);
|
||||
});
|
||||
test('skipped test', () => {
|
||||
console.log('\\n%%should not run');
|
||||
});
|
||||
`,
|
||||
});
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.passed).toBe(1);
|
||||
expect(result.failed).toBe(0);
|
||||
expect(result.outputLines).toEqual([
|
||||
'beforeAll',
|
||||
'test body',
|
||||
'afterAll',
|
||||
]);
|
||||
expect(result.output).not.toContain('should not run');
|
||||
});
|
||||
|
||||
test('test.fail.only with failing beforeEach should still prevent test and run afterEach', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'a.test.js': `
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.beforeEach(async () => {
|
||||
console.log('beforeEach');
|
||||
throw new Error('beforeEach failure');
|
||||
});
|
||||
|
||||
test.afterEach(async () => {
|
||||
console.log('afterEach');
|
||||
});
|
||||
|
||||
test.fail.only('failing test', async () => {
|
||||
console.log('test body');
|
||||
expect(1 + 1).toBe(3);
|
||||
});
|
||||
`,
|
||||
});
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.passed).toBe(1);
|
||||
expect(result.failed).toBe(0);
|
||||
expect(result.output).toContain('beforeEach\nafterEach');
|
||||
expect(result.output).not.toContain('test body');
|
||||
});
|
||||
Loading…
Reference in a new issue