|
1 | 1 | import { defineConfig, devices } from '@playwright/test'; |
2 | 2 | import dotenv from 'dotenv'; |
3 | | -import path from 'path'; |
| 3 | + |
4 | 4 | if (!process.env.CI) { |
5 | 5 | dotenv.config(); |
6 | 6 | } |
7 | | -//dotenv.config({ path: path.resolve(__dirname, '.env') }); |
8 | | - |
9 | | -/** |
10 | | - * Read environment variables from file. |
11 | | - * https://github.com/motdotla/dotenv |
12 | | - */ |
13 | | -// import dotenv from 'dotenv'; |
14 | | -// import path from 'path'; |
15 | | -// dotenv.config({ path: path.resolve(__dirname, '.env') }); |
16 | | - |
17 | | -/** |
18 | | - * See https://playwright.dev/docs/test-configuration. |
19 | | - */ |
20 | 7 | export default defineConfig({ |
21 | 8 | testDir: './tests', |
22 | | - /* Run tests in files in parallel */ |
23 | 9 | fullyParallel: true, |
24 | | - /* Fail the build on CI if you accidentally left test.only in the source code. */ |
25 | 10 | forbidOnly: !!process.env.CI, |
26 | | - /* Retry on CI only */ |
27 | 11 | retries: process.env.CI ? 2 : 0, |
28 | | - /* Opt out of parallel tests on CI. */ |
29 | 12 | workers: process.env.CI ? 1 : undefined, |
30 | | - /* Reporter to use. See https://playwright.dev/docs/test-reporters */ |
31 | 13 | reporter: 'html', |
32 | | - /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ |
| 14 | + |
| 15 | + // Configurações globais (Trace e Screenshot) |
33 | 16 | use: { |
34 | 17 | trace: 'on-first-retry', |
35 | 18 | screenshot: 'only-on-failure', |
36 | | - extraHTTPHeaders: { |
37 | | - Authorization: `Bearer ${process.env.GOREST_TOKEN}`, |
38 | | - }, |
39 | 19 | }, |
40 | 20 |
|
41 | | - /* Configure projects for major browsers */ |
42 | 21 | projects: [ |
43 | 22 | { |
44 | 23 | name: 'API-Tests', |
45 | | - testMatch: /.*\.api\.spec\.ts/, // Só arquivos de API |
46 | | - use: { baseURL: 'https://gorest.co.in' }, |
| 24 | + testMatch: /.*\.spec\.ts/, |
| 25 | + testDir: './tests/api', // Organização por pasta |
| 26 | + use: { |
| 27 | + baseURL: process.env.GOREST_BASE_URL, // Pega da Secret do GitHub |
| 28 | + extraHTTPHeaders: { |
| 29 | + Authorization: `Bearer ${process.env.GOREST_TOKEN}`, // Token isolado aqui |
| 30 | + }, |
| 31 | + }, |
47 | 32 | }, |
48 | 33 | { |
49 | 34 | name: 'E2E-Tests', |
50 | | - testMatch: /.*\.e2e\.spec\.ts/, // Só arquivos de site |
51 | | - use: { baseURL: 'https://www.saucedemo.com' }, |
52 | | - }, |
53 | | - { |
54 | | - name: 'chromium', |
55 | | - use: { ...devices['Desktop Chrome'] }, |
| 35 | + testMatch: /.*\.spec\.ts/, |
| 36 | + testDir: './tests/e2e', // Organização por pasta |
| 37 | + use: { |
| 38 | + ...devices['Desktop Chrome'], |
| 39 | + baseURL: 'https://www.saucedemo.com', // URL de UI |
| 40 | + }, |
56 | 41 | }, |
57 | | - |
58 | | - { |
59 | | - name: 'firefox', |
60 | | - use: { ...devices['Desktop Firefox'] }, |
61 | | - }, |
62 | | - |
63 | | - /* Test against mobile viewports. */ |
64 | | - // { |
65 | | - // name: 'Mobile Chrome', |
66 | | - // use: { ...devices['Pixel 5'] }, |
67 | | - // }, |
68 | | - // { |
69 | | - // name: 'Mobile Safari', |
70 | | - // use: { ...devices['iPhone 12'] }, |
71 | | - // }, |
72 | | - |
73 | | - /* Test against branded browsers. */ |
74 | | - // { |
75 | | - // name: 'Microsoft Edge', |
76 | | - // use: { ...devices['Desktop Edge'], channel: 'msedge' }, |
77 | | - // }, |
78 | | - // { |
79 | | - // name: 'Google Chrome', |
80 | | - // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, |
81 | | - // }, |
82 | 42 | ], |
83 | | - |
84 | | - /* Run your local dev server before starting the tests */ |
85 | | - // webServer: { |
86 | | - // command: 'npm run start', |
87 | | - // url: 'http://localhost:3000', |
88 | | - // reuseExistingServer: !process.env.CI, |
89 | | - // }, |
90 | 43 | }); |
0 commit comments