-
Notifications
You must be signed in to change notification settings - Fork 131
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
Showing
1 changed file
with
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Meta } from '@storybook/addon-docs'; | ||
|
||
<Meta title="Utils/coverage" /> | ||
|
||
## `getBladeCoverage` | ||
|
||
This utility function calculates the blade usage coverage in percentage of the DOM elements on a web page. | ||
|
||
|
||
```js dark | ||
import { getBladeCoverage } from '@razorpay/blade/coverage'; | ||
|
||
const { bladeCoverage, totalNodes, bladeNodes } = getBladeCoverage(); | ||
``` | ||
|
||
- `bladeCoverage`: The percentage of blade nodes in the total nodes. | ||
- `totalNodes`: Total number of DOM nodes. | ||
- `bladeNodes`: Number of blade nodes. | ||
|
||
## `assertBladeCoverage` | ||
|
||
This utility function asserts that the calculated blade coverage meets a specified threshold. | ||
|
||
Parameters: | ||
- `page`: Playwright page object. | ||
- `expect`: @playwright/test expect function. | ||
- `threshold` (optional): Minimum threshold for blade coverage (default is 70). | ||
|
||
### Example | ||
|
||
```js dark | ||
import { test, expect } from '@playwright/test'; | ||
import { assertBladeCoverage } from '@razorpay/blade/coverage'; | ||
|
||
test.describe.parallel('Test Home @flow=home', () => { | ||
test('should have blade coverage more than 70% @priority=normal', async ({ page }) => { | ||
await page.goto('/'); | ||
|
||
await assertBladeCoverage({ page, expect, threshold: 70 }); | ||
}); | ||
}); | ||
``` |