Skip to content

Commit

Permalink
local support fixture override
Browse files Browse the repository at this point in the history
  • Loading branch information
4DvAnCeBoY committed Sep 11, 2024
1 parent bc6c9e2 commit 051ad6c
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 1 deletion.
10 changes: 10 additions & 0 deletions playwright-test-js/lambdatest-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const { chromium, _android } = require('playwright')
const cp = require('child_process');
const playwrightClientVersion = cp.execSync('npx playwright --version').toString().trim().split(' ')[1];

if (process.env.executeOn !== "local"){

// LambdaTest capabilities
const capabilities = {
'browserName': 'Chrome', // Browsers allowed: `Chrome`, `MicrosoftEdge`, `pw-chromium`, `pw-firefox` and `pw-webkit`
Expand Down Expand Up @@ -128,3 +130,11 @@ exports.test = base.test.extend({
{ auto: true },
],
});
}else {
// Fallback to local if `executeOn` is not set to `lambdatest`
exports.test = base.test.extend({
page: async ({ page }, use) => {
await use(page); // Running locally
}
});
}
4 changes: 3 additions & 1 deletion playwright-test-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"description": "Sample project to run playwright tests using playwright runner on LambdaTest platform",
"scripts": {
"test": "npx playwright test --config=./playwright.config.js",
"testAndroid": "npx playwright test --config=./playwrightAndroid.config.js"
"testAndroid": "npx playwright test --config=./playwrightAndroid.config.js",
"testLocal": "npx playwright test --config=./playwright.config.local.js"

},
"devDependencies": {
"@playwright/test": "^1.35.0",
Expand Down
68 changes: 68 additions & 0 deletions playwright-test-js/playwright-report/index.html

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions playwright-test-js/playwright.config.local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// @ts-check
const { defineConfig, devices } = require('@playwright/test');

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config({ path: path.resolve(__dirname, '.env') });

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: 'tests',
testMatch: '**/*.spec.js',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});

0 comments on commit 051ad6c

Please sign in to comment.