Skip to content

Commit

Permalink
fix: added camera options
Browse files Browse the repository at this point in the history
  • Loading branch information
felixindrawan committed Aug 27, 2024
1 parent 8c69eac commit 07d826d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 120 deletions.
92 changes: 36 additions & 56 deletions VINScanner/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,68 +11,48 @@ import { defineConfig, devices } from "@playwright/test";
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: "./tests",
/* 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://localhost:3000",

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

/* Configure projects for major browsers */
testDir: "./tests" /* Configure projects for major browsers */,
projects: [
{
name: "VINScanner - chromium",
use: { ...devices["Desktop Chrome"] },
name: "chromium",
use: {
...devices["Desktop Chrome"],
launchOptions: {
args: [
"--disable-web-security",
"--enable-web-rtc",
"--use-fake-ui-for-media-stream",
"--use-fake-device-for-media-stream",
],
},
contextOptions: {
/* Camera permission */
permissions: ["camera"],
ignoreHTTPSErrors: true,
},
},
},

{
name: "VINScanner - firefox",
use: { ...devices["Desktop Firefox"] },
name: "firefox",
use: {
...devices["Desktop Firefox"],
launchOptions: {
args: ["--use-fake-device-for-media-stream", "--use-fake-ui-for-media-stream"],
firefoxUserPrefs: {
"permissions.default.camera": 1, // Allow camera access automatically
"media.navigator.streams.fake": true, // Use fake streams if needed
},
},
},
},

{
name: "VINScanner - webkit",
use: { ...devices["Desktop Safari"] },
name: "webkit",
use: {
...devices["Desktop Safari"],
launchOptions: {
args: ["--disable-web-security", "--enable-web-rtc"],
},
},
},

/* 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,
// },
});
25 changes: 0 additions & 25 deletions VINScanner/tests/example.spec.ts

This file was deleted.

8 changes: 8 additions & 0 deletions VINScanner/tests/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { test, expect } from "@playwright/test";

test("load local page", async ({ page }) => {
await page.goto("/VINScanner/index.html");

// Expects page to have a heading with the name of Installation.
await expect(await page.title()).toContain("VIN Scanner");
});
41 changes: 2 additions & 39 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig, devices } from "@playwright/test";
import { defineConfig } from "@playwright/test";

/**
* Read environment variables from file.
Expand Down Expand Up @@ -31,53 +31,16 @@ export default defineConfig({
trace: "on-first-retry",
},

/* Configure projects for major browsers */
/* Configure projects */
projects: [
{
name: "VINScanner",
testDir: "./VINScanner/tests",
},

// {
// 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 07d826d

Please sign in to comment.