Skip to content

Commit

Permalink
tests(pw): add env id (#46)
Browse files Browse the repository at this point in the history
* tests(pw): add env id

* tests(cy): add env id
  • Loading branch information
Adnan Rahić authored Oct 7, 2024
1 parent a3b8e5d commit 3be5812
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
TRACETEST_API_TOKEN=
POKESHOP_DEMO_URL=http://localhost:8081
TRACETEST_AGENT_API_KEY=
TRACETEST_ENVIRONMENT_ID=
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = defineConfig({
env: {
TRACETEST_API_TOKEN: process.env.TRACETEST_API_TOKEN,
TRACETEST_SERVER_URL: process.env.TRACETEST_SERVER_URL || 'https://app.tracetest.io',
TRACETEST_ENVIRONMENT_ID: process.env.TRACETEST_ENVIRONMENT_ID
},
setupNodeEvents() {
// implement node event listeners here
Expand Down
8 changes: 7 additions & 1 deletion cypress/e2e/1-getting-started/home.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Tracetest, { Types } from '@tracetest/cypress';

const TRACETEST_API_TOKEN = Cypress.env('TRACETEST_API_TOKEN') || '';
const TRACETEST_ENVIRONMENT_ID = Cypress.env('TRACETEST_ENVIRONMENT_ID') || '';
const TRACETEST_SERVER_URL = Cypress.env('TRACETEST_SERVER_URL') || 'https://app.tracetest.io';

let tracetest: Types.TracetestCypress | undefined = undefined;
Expand Down Expand Up @@ -29,7 +30,12 @@ spec:

describe('Home', { defaultCommandTimeout: 80000 }, () => {
before(done => {
Tracetest({ apiToken: TRACETEST_API_TOKEN, serverUrl: TRACETEST_SERVER_URL, serverPath: '' }).then(instance => {
Tracetest({
apiToken: TRACETEST_API_TOKEN,
environmentId: TRACETEST_ENVIRONMENT_ID,
serverUrl: TRACETEST_SERVER_URL,
serverPath: ''
}).then(instance => {
tracetest = instance;
tracetest
.setOptions({
Expand Down
9 changes: 7 additions & 2 deletions playwright/home.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';
import Tracetest, { Types } from '@tracetest/playwright';

const { TRACETEST_API_TOKEN = '', TRACETEST_SERVER_URL = 'https://app.tracetest.io' } = process.env;
const { TRACETEST_API_TOKEN = '', TRACETEST_SERVER_URL = 'https://app.tracetest.io', TRACETEST_ENVIRONMENT_ID = '' } = process.env;

let tracetest: Types.TracetestPlaywright | undefined = undefined;

Expand Down Expand Up @@ -30,7 +30,12 @@ spec:
`;

test.beforeAll(async () => {
tracetest = await Tracetest({ apiToken: TRACETEST_API_TOKEN, serverUrl: TRACETEST_SERVER_URL, serverPath: '' });
tracetest = await Tracetest({
apiToken: TRACETEST_API_TOKEN,
serverUrl: TRACETEST_SERVER_URL,
serverPath: '',
environmentId: TRACETEST_ENVIRONMENT_ID,
});

await tracetest.setOptions({
'Playwright: imports a pokemon': {
Expand Down

0 comments on commit 3be5812

Please sign in to comment.