-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7bbe46
commit 4f13803
Showing
5 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {TestDecoratedMethod} from "./test.decorator"; | ||
|
||
/** | ||
* Marks a @test as "should fail". | ||
* Playwright Test runs this test and ensures that it is actually failing. | ||
* This is useful for documentation purposes to acknowledge that some functionality is broken until it is fixed. | ||
*/ | ||
export const fail = (reason?: string) => function(originalMethod: any, context?: any) { | ||
if ((originalMethod as TestDecoratedMethod)?.testDecorator) { | ||
originalMethod.testDecorator.fail = reason || true; | ||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import playwright, {expect} from "@playwright/test"; | ||
import {suite, test, fail} from "../lib"; | ||
|
||
playwright.describe('@fail decorator', () => { | ||
playwright.describe('with @test', () => { | ||
const called: string[] = []; | ||
|
||
@suite() | ||
class FocusedSuite { | ||
@fail() | ||
@test() | ||
failingTest() { | ||
called.push('failingTest'); | ||
expect(true).toBe(false); | ||
} | ||
} | ||
|
||
playwright('@fail decorator should not throw error when test fails', () => { | ||
// is called and not throw error | ||
expect(called).toEqual(['failingTest']); | ||
}); | ||
}); | ||
}); |