-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add options to run all dtc test files in a project (#6)
* add options to run all dts test files in a project * fix functions tests * fix playwrite * Create TestCaseExecution * Bump version * Update dependencies * Download playwright browser * Install playwright --------- Co-authored-by: Ab C <[email protected]>
- Loading branch information
1 parent
a581baf
commit d746ecb
Showing
29 changed files
with
323 additions
and
103 deletions.
There are no files selected for viewing
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
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
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
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 |
---|---|---|
@@ -1,23 +1,26 @@ | ||
import {Runner, TestCase, Plugins} from '@cgauge/dtc' | ||
import {Runner, TestCaseExecution, Plugins} from '@cgauge/dtc' | ||
import {spawnSync} from 'node:child_process' | ||
import nodeAssert from 'node:assert' | ||
import * as url from 'url' | ||
|
||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) | ||
|
||
export class PlaywrightRunner implements Runner { | ||
constructor(private args: string[] = []) {} | ||
|
||
async run(path: string, _testCase: TestCase, _plugins: Plugins, type: string, config?: string) { | ||
spawnSync(`npx playwright test ${this.args.join(' ')} ${__dirname}`, { | ||
async run(testCaseExecutions: TestCaseExecution[], _plugins: Plugins, type: string, config?: string) { | ||
const childProcess = spawnSync(`npx playwright test ${this.args.join(' ')} ${__dirname}`, { | ||
stdio: 'inherit', | ||
shell: true, | ||
cwd: process.cwd(), | ||
env: { | ||
...process.env, | ||
DTC_PLAYWRIGHT_FILE_PATH: path, | ||
...(testCaseExecutions.length === 1 && {DTC_PLAYWRIGHT_PATH: testCaseExecutions[0].filePath}), | ||
DTC_PLAYWRIGHT_TYPE: type, | ||
DTC_PLAYWRIGHT_CONFIG: config, | ||
}, | ||
}) | ||
|
||
nodeAssert.equal(childProcess.status, 0) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import {executeTestCase, resolveConfig} from '@cgauge/dtc' | ||
import {test} from '@playwright/test' | ||
|
||
const path = String(process.env.DTC_PLAYWRIGHT_FILE_PATH) | ||
const path = process.env.DTC_PLAYWRIGHT_PATH | ||
const type = String(process.env.DTC_PLAYWRIGHT_TYPE) | ||
const config = String(process.env.DTC_PLAYWRIGHT_CONFIG) | ||
|
||
console.log(path, type, config) | ||
const {testCaseExecutions, plugins} = await resolveConfig(path, config) | ||
|
||
const {testCase, plugins} = await resolveConfig(path, config) | ||
|
||
test(testCase.name, async ({page}) => executeTestCase(testCase[type], plugins[type], {page})) | ||
for (const {filePath, testCase} of testCaseExecutions) { | ||
test(testCase.name, async ({page}) => executeTestCase(testCase[type], plugins[type], filePath, {page})) | ||
} |
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
File renamed without changes.
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,58 @@ | ||
import {fileURLToPath} from 'url' | ||
import {dirname} from 'path' | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)) | ||
|
||
export default { | ||
name: 'Test case 2', | ||
playwright: { | ||
arrange: { | ||
url: `file://${__dirname}/login.html`, | ||
actions: [ | ||
{ | ||
target: 'Username', | ||
fill: '', | ||
}, | ||
{ | ||
target: { | ||
name: 'getByPlaceholder', | ||
args: ['Your password'], | ||
}, | ||
action: { | ||
name: 'fill', | ||
args: [''], | ||
}, | ||
}, | ||
{ | ||
target: { | ||
name: 'getByRole', | ||
args: [ | ||
'button', | ||
{ | ||
type: 'submit', | ||
}, | ||
], | ||
}, | ||
action: { | ||
name: 'click', | ||
}, | ||
}, | ||
{ | ||
target: "input#username[required]:invalid", | ||
toBeVisible: true, | ||
}, | ||
], | ||
}, | ||
act: { | ||
url: `file://${__dirname}/index.html`, | ||
}, | ||
assert: { | ||
playwright: [ | ||
{ | ||
target: "Index page", | ||
toBeVisible: true, | ||
}, | ||
], | ||
}, | ||
}, | ||
} |
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
Oops, something went wrong.