Skip to content

Commit 3688e09

Browse files
committed
chore(tests): Add @utils alias for integration tests.
1 parent a338b1b commit 3688e09

File tree

42 files changed

+353
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+353
-120
lines changed

packages/integration-tests/.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,12 @@ module.exports = {
88
parserOptions: {
99
sourceType: 'module',
1010
},
11+
settings: {
12+
'import/resolver': {
13+
alias: {
14+
map: [['@utils', './utils']],
15+
extensions: ['.ts', '.js'],
16+
},
17+
},
18+
},
1119
};

packages/integration-tests/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ suites/
2727

2828
## Writing Tests
2929

30+
### Utils
31+
32+
Test utilities can be imported using `@utils` alias from tests and test subjects.
33+
3034
### Helpers
3135

32-
`utils/helpers.ts` contains helpers that could be used in assertions (`test.ts`). These helpers define a convenient and reliable API to interact with Playwright's native API. It's highly recommended to define all common patterns of Playwright usage in helpers.
36+
`@utils/helpers.ts` contains helpers that could be used in assertions (`test.ts`). These helpers define a convenient and reliable API to interact with Playwright's native API. It's highly recommended to define all common patterns of Playwright usage in helpers.
3337

3438
### Fixtures
3539

36-
[Fixtures](https://playwright.dev/docs/api/class-fixtures) allows us to define the globals and test-specific information in assertion groups (`test.ts` files). In it's current state, `fixtures.ts` contains an extension over the pure version of `test()` function of Playwright. All the tests should import `sentryTest` function from `utils/fixtures.ts` instead of `@playwright/test` to be able to access the extra fixtures.
40+
[Fixtures](https://playwright.dev/docs/api/class-fixtures) allows us to define the globals and test-specific information in assertion groups (`test.ts` files). In it's current state, `fixtures.ts` contains an extension over the pure version of `test()` function of Playwright. All the tests should import `sentryTest` function from `@utils/fixtures` instead of `@playwright/test` to be able to access the extra fixtures.
3741

3842
## Running Tests Locally
3943

packages/integration-tests/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
"test": "playwright test ./suites"
2020
},
2121
"dependencies": {
22-
"@playwright/test": "^1.17.0",
22+
"@babel/preset-typescript": "^7.16.7",
23+
"@playwright/test": "^1.18.0-rc1",
2324
"babel-loader": "^8.2.2",
25+
"eslint-import-resolver-alias": "^1.1.2",
2426
"handlebars-loader": "^1.7.1",
2527
"html-webpack-plugin": "^5.5.0",
26-
"playwright": "^1.17.1",
28+
"playwright": "^1.18.0-rc1",
2729
"typescript": "^4.5.2",
2830
"webpack": "^5.52.0"
2931
}

packages/integration-tests/suites/public-api/addBreadcrumb/empty_obj/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { expect } from '@playwright/test';
2-
3-
import { sentryTest } from '../../../../utils/fixtures';
4-
import { getSentryRequest } from '../../../../utils/helpers';
2+
import { sentryTest } from '@utils/fixtures';
3+
import { getSentryRequest } from '@utils/helpers';
54

65
sentryTest(
76
'should add an empty breadcrumb initialized with a timestamp, when an empty object is given',

packages/integration-tests/suites/public-api/addBreadcrumb/multiple_breadcrumbs/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { expect } from '@playwright/test';
2-
3-
import { sentryTest } from '../../../../utils/fixtures';
4-
import { getSentryRequest } from '../../../../utils/helpers';
2+
import { sentryTest } from '@utils/fixtures';
3+
import { getSentryRequest } from '@utils/helpers';
54

65
sentryTest('should add multiple breadcrumbs', async ({ getLocalTestPath, page }) => {
76
const url = await getLocalTestPath({ testDir: __dirname });

packages/integration-tests/suites/public-api/addBreadcrumb/simple_breadcrumb/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { expect } from '@playwright/test';
2-
3-
import { sentryTest } from '../../../../utils/fixtures';
4-
import { getSentryRequest } from '../../../../utils/helpers';
2+
import { sentryTest } from '@utils/fixtures';
3+
import { getSentryRequest } from '@utils/helpers';
54

65
sentryTest('should add a simple breadcrumb', async ({ getLocalTestPath, page }) => {
76
const url = await getLocalTestPath({ testDir: __dirname });

packages/integration-tests/suites/public-api/addBreadcrumb/undefined_arg/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { expect } from '@playwright/test';
2-
3-
import { sentryTest } from '../../../../utils/fixtures';
4-
import { getSentryRequest } from '../../../../utils/helpers';
2+
import { sentryTest } from '@utils/fixtures';
3+
import { getSentryRequest } from '@utils/helpers';
54

65
sentryTest(
76
'should add an empty breadcrumb initialized with a timestamp, when no argument is given',

packages/integration-tests/suites/public-api/captureException/empty_obj/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { expect } from '@playwright/test';
2-
3-
import { sentryTest } from '../../../../utils/fixtures';
4-
import { getSentryRequest } from '../../../../utils/helpers';
2+
import { sentryTest } from '@utils/fixtures';
3+
import { getSentryRequest } from '@utils/helpers';
54

65
sentryTest('should capture an empty object', async ({ getLocalTestPath, page }) => {
76
const url = await getLocalTestPath({ testDir: __dirname });

packages/integration-tests/suites/public-api/captureException/simple_error/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { expect } from '@playwright/test';
2-
3-
import { sentryTest } from '../../../../utils/fixtures';
4-
import { getSentryRequest } from '../../../../utils/helpers';
2+
import { sentryTest } from '@utils/fixtures';
3+
import { getSentryRequest } from '@utils/helpers';
54

65
sentryTest('should capture a simple error with message', async ({ getLocalTestPath, page }) => {
76
const url = await getLocalTestPath({ testDir: __dirname });

packages/integration-tests/suites/public-api/captureException/undefined_arg/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { expect } from '@playwright/test';
2-
3-
import { sentryTest } from '../../../../utils/fixtures';
4-
import { getSentryRequest } from '../../../../utils/helpers';
2+
import { sentryTest } from '@utils/fixtures';
3+
import { getSentryRequest } from '@utils/helpers';
54

65
sentryTest('should capture an undefined error when no arguments are provided', async ({ getLocalTestPath, page }) => {
76
const url = await getLocalTestPath({ testDir: __dirname });

0 commit comments

Comments
 (0)