From 3be5812abce5efaedf426c29b11da5b0b5b3ea64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adnan=20Rahi=C4=87?= Date: Mon, 7 Oct 2024 20:58:46 +0200 Subject: [PATCH] tests(pw): add env id (#46) * tests(pw): add env id * tests(cy): add env id --- .env.template | 1 + cypress.config.ts | 1 + cypress/e2e/1-getting-started/home.cy.ts | 8 +++++++- playwright/home.spec.ts | 9 +++++++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.env.template b/.env.template index 15db539..62541f1 100644 --- a/.env.template +++ b/.env.template @@ -1,3 +1,4 @@ TRACETEST_API_TOKEN= POKESHOP_DEMO_URL=http://localhost:8081 TRACETEST_AGENT_API_KEY= +TRACETEST_ENVIRONMENT_ID= \ No newline at end of file diff --git a/cypress.config.ts b/cypress.config.ts index 72172e5..508e604 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -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 diff --git a/cypress/e2e/1-getting-started/home.cy.ts b/cypress/e2e/1-getting-started/home.cy.ts index 9bb2400..07ac051 100644 --- a/cypress/e2e/1-getting-started/home.cy.ts +++ b/cypress/e2e/1-getting-started/home.cy.ts @@ -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; @@ -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({ diff --git a/playwright/home.spec.ts b/playwright/home.spec.ts index 53526bd..c094a09 100644 --- a/playwright/home.spec.ts +++ b/playwright/home.spec.ts @@ -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; @@ -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': {