Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/integration-tests/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@ module.exports = {
parserOptions: {
sourceType: 'module',
},
settings: {
'import/resolver': {
alias: {
map: [['@utils', './utils']],
extensions: ['.ts', '.js'],
},
},
},
};
8 changes: 6 additions & 2 deletions packages/integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ suites/

## Writing Tests

### Utils

Test utilities can be imported using `@utils` alias from tests and test subjects.

### Helpers

`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.
`@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.

### Fixtures

[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.
[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.

## Running Tests Locally

Expand Down
6 changes: 4 additions & 2 deletions packages/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
"test": "playwright test ./suites"
},
"dependencies": {
"@playwright/test": "^1.17.0",
"@babel/preset-typescript": "^7.16.7",
"@playwright/test": "^1.18.0-rc1",
"babel-loader": "^8.2.2",
"eslint-import-resolver-alias": "^1.1.2",
"handlebars-loader": "^1.7.1",
"html-webpack-plugin": "^5.5.0",
"playwright": "^1.17.1",
"playwright": "^1.18.0-rc1",
"typescript": "^4.5.2",
"webpack": "^5.52.0"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh I don't see the value in the relative import here, it just makes things more confusing. Any thoughts?

Copy link
Collaborator Author

@onurtemizkan onurtemizkan Jan 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, actually I thought so. But as we're introducing this alias for subjects, it seemed less confusing to have the same behaviour on the assertions. I'm totally fine with removing aliases for assertions. It requires too much custom configuration anyways.


sentryTest(
'should add an empty breadcrumb initialized with a timestamp, when an empty object is given',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should add multiple breadcrumbs', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should add a simple breadcrumb', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest(
'should add an empty breadcrumb initialized with a timestamp, when no argument is given',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should capture an empty object', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should capture a simple error with message', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should capture an undefined error when no arguments are provided', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should capture a simple message string', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getMultipleSentryRequests } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getMultipleSentryRequests } from '@utils/helpers';

sentryTest('should capture with different severity levels', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should clear previously set properties of a scope', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should set different properties of a scope', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should record multiple contexts', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should normalize non-serializable context', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should set a simple context', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should record multiple extras of different types', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should normalize non-serializable extra', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should record a simple extra object', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should set extras from multiple consecutive calls', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should record an extras object', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should not accept non-primitive tags', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should set primitive tags', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should not accept non-primitive tags', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryRequest } from '@utils/helpers';

sentryTest('should set primitive tags', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getMultipleSentryRequests } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getMultipleSentryRequests } from '@utils/helpers';

sentryTest('should unset user', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getMultipleSentryRequests } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getMultipleSentryRequests } from '@utils/helpers';

sentryTest('should update user', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { sentryTest } from '@utils/fixtures';

sentryTest('should inject dialog script into <head> with correct attributes', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryTransactionRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryTransactionRequest } from '@utils/helpers';

sentryTest('should report a transaction in an envelope', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getMultipleSentryRequests } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getMultipleSentryRequests } from '@utils/helpers';

sentryTest('should allow nested scoping', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryTransactionRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryTransactionRequest } from '@utils/helpers';

sentryTest(
'should create a pageload transaction based on `sentry-trace` <meta>',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryTransactionRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryTransactionRequest } from '@utils/helpers';

sentryTest('should create a navigation transaction on page navigation', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryTransactionRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryTransactionRequest } from '@utils/helpers';

sentryTest('should create a pageload transaction', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryTransactionRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryTransactionRequest } from '@utils/helpers';

sentryTest('should add browser-related spans to pageload transaction', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect, Route } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryTransactionRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryTransactionRequest } from '@utils/helpers';

sentryTest('should add resource spans to pageload transaction', async ({ getLocalTestPath, page }) => {
// Intercepting asset requests to avoid network-related flakiness and random retries (on Firefox).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect, Request } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryTransactionRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryTransactionRequest } from '@utils/helpers';

sentryTest('should create spans for multiple fetch requests', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
5 changes: 2 additions & 3 deletions packages/integration-tests/suites/tracing/request/xhr/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect, Request } from '@playwright/test';

import { sentryTest } from '../../../../utils/fixtures';
import { getSentryTransactionRequest } from '../../../../utils/helpers';
import { sentryTest } from '@utils/fixtures';
import { getSentryTransactionRequest } from '@utils/helpers';

sentryTest('should create spans for multiple XHR requests', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });
Expand Down
Loading