Skip to content

Commit

Permalink
docs: add coverage utils
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Dec 8, 2023
1 parent 388f9fb commit c2c53cb
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions packages/blade/docs/utils/coverge.stories.mdx
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 });
});
});
```

0 comments on commit c2c53cb

Please sign in to comment.