-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for sync-playwright feature
- Loading branch information
1 parent
ce8c626
commit 27bafa2
Showing
9 changed files
with
250 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
packages/cli/e2e/__tests__/fixtures/test-playwright-project/checkly.config.original.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { defineConfig } from 'checkly' | ||
|
||
const config = defineConfig({ | ||
projectName: 'Test Playwright Project', | ||
logicalId: 'test-playwright-project', | ||
repoUrl: 'https://github.com/checkly/checkly-cli', | ||
checks: { | ||
locations: ['us-east-1', 'eu-west-1'], | ||
tags: ['mac'], | ||
runtimeId: '2022.10', | ||
checkMatch: '**/*.check.ts', | ||
browserChecks: { | ||
testMatch: '**/__checks__/*.test.ts', | ||
}, | ||
}, | ||
cli: { | ||
runLocation: 'us-east-1', | ||
}, | ||
}) | ||
|
||
export default config |
21 changes: 21 additions & 0 deletions
21
packages/cli/e2e/__tests__/fixtures/test-playwright-project/checkly.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { defineConfig } from 'checkly' | ||
|
||
const config = defineConfig({ | ||
projectName: 'Test Playwright Project', | ||
logicalId: 'test-playwright-project', | ||
repoUrl: 'https://github.com/checkly/checkly-cli', | ||
checks: { | ||
locations: ['us-east-1', 'eu-west-1'], | ||
tags: ['mac'], | ||
runtimeId: '2022.10', | ||
checkMatch: '**/*.check.ts', | ||
browserChecks: { | ||
testMatch: '**/__checks__/*.test.ts', | ||
}, | ||
}, | ||
cli: { | ||
runLocation: 'us-east-1', | ||
}, | ||
}) | ||
|
||
export default config |
23 changes: 23 additions & 0 deletions
23
packages/cli/e2e/__tests__/fixtures/test-playwright-project/playwright.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
export default defineConfig({ | ||
testDir: 'tests', | ||
timeout: 1234, | ||
use: { | ||
baseURL: 'http://127.0.0.1:3000', | ||
extraHTTPHeaders: { | ||
foo: 'bar', | ||
}, | ||
}, | ||
expect: { | ||
toMatchSnapshot: { | ||
maxDiffPixelRatio: 1, | ||
}, | ||
}, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { runChecklyCli } from '../run-checkly' | ||
import * as path from 'path' | ||
import { loadChecklyConfig } from '../../src/services/checkly-config-loader' | ||
import * as fs from 'fs' | ||
|
||
describe('sync-playwright', () => { | ||
// Since we are modifying the file let's keep it clean after each test | ||
afterEach(() => { | ||
const configPath = path.join(__dirname, 'fixtures', 'test-playwright-project') | ||
fs.copyFileSync(path.join(configPath, 'checkly.config.original.ts'), path.join(configPath, 'checkly.config.ts')) | ||
}) | ||
|
||
it('should copy playwright config into checkly config', async () => { | ||
const { status, stdout } = await runChecklyCli({ | ||
args: ['sync-playwright'], | ||
directory: path.join(__dirname, 'fixtures', 'test-playwright-project'), | ||
}) | ||
expect(status).toBe(0) | ||
expect(stdout).toContain('Successfully sync') | ||
const checklyConfig = await loadChecklyConfig(path.join(__dirname, 'fixtures', 'test-playwright-project')) | ||
expect(checklyConfig.config?.checks?.browserChecks?.playwrightConfig).toBeDefined() | ||
expect(checklyConfig.config?.checks?.browserChecks?.playwrightConfig?.timeout).toEqual(1234) | ||
expect(checklyConfig.config?.checks?.browserChecks?.playwrightConfig?.use).toBeDefined() | ||
expect(checklyConfig.config?.checks?.browserChecks?.playwrightConfig?.use?.baseURL).toEqual('http://127.0.0.1:3000') | ||
expect(checklyConfig.config?.checks?.browserChecks?.playwrightConfig?.expect).toBeDefined() | ||
}) | ||
|
||
it('should fail if no playwright config file exists', async () => { | ||
const { status, stdout } = await runChecklyCli({ | ||
args: ['sync-playwright'], | ||
directory: path.join(__dirname, 'fixtures', 'test-project'), | ||
}) | ||
expect(status).toBe(1) | ||
expect(stdout).toContain('Could not find any playwright.config file.') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/create-cli/e2e/__tests__/fixtures/playwright-project/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "dummy-project", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"checkly": "latest", | ||
"ts-node": "latest", | ||
"typescript": "latest" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/create-cli/e2e/__tests__/fixtures/playwright-project/playwright.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
export default defineConfig({ | ||
testDir: 'tests', | ||
timeout: 1234, | ||
use: { | ||
baseURL: 'http://127.0.0.1:3000', | ||
extraHTTPHeaders: { | ||
foo: 'bar', | ||
}, | ||
}, | ||
expect: { | ||
toMatchSnapshot: { | ||
maxDiffPixelRatio: 1, | ||
}, | ||
}, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
], | ||
}) |