-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
193 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env node | ||
import { | ||
logError, | ||
logInstallDependencies, | ||
logUseTypeScript, | ||
promptGithubActions, | ||
promptRootDir, | ||
} from './cli'; | ||
import { detectTypeScript, detectYarn, writeConfig } from './config'; | ||
import { | ||
addDevDependencies, | ||
installDependencies, | ||
readPackageJson, | ||
} from './packageJson'; | ||
|
||
export const create = async (): Promise<void> => { | ||
try { | ||
// run this first to ensure package.json | ||
await readPackageJson(); | ||
|
||
const rootDir = await promptRootDir(); | ||
|
||
const useTypeScript = await detectTypeScript(); | ||
logUseTypeScript(useTypeScript); | ||
|
||
await promptGithubActions(); | ||
|
||
await writeConfig({ rootDir, useTypeScript }); | ||
|
||
const packages = await addDevDependencies(useTypeScript); | ||
|
||
const isYarn = detectYarn(); | ||
logInstallDependencies(packages, isYarn); | ||
installDependencies(isYarn); | ||
} catch (error) { | ||
logError(error); | ||
process.exit(1); | ||
} | ||
}; |
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,39 +1,9 @@ | ||
#!/usr/bin/env node | ||
import { install as installCi } from 'playwright-ci'; | ||
import { | ||
logError, | ||
logInstallDependencies, | ||
logUseTypeScript, | ||
promptRootDir, | ||
} from './cli'; | ||
import { detectTypeScript, detectYarn, writeConfig } from './config'; | ||
import { | ||
addDevDependencies, | ||
installDependencies, | ||
readPackageJson, | ||
} from './packageJson'; | ||
import { create } from './create'; | ||
|
||
(async (): Promise<void> => { | ||
try { | ||
// run this first to ensure package.json | ||
await readPackageJson(); | ||
const isCLI = !module.parent; | ||
if (isCLI) { | ||
create(); | ||
} | ||
|
||
const rootDir = await promptRootDir(); | ||
|
||
const useTypeScript = await detectTypeScript(); | ||
logUseTypeScript(useTypeScript); | ||
|
||
await installCi(true); | ||
|
||
await writeConfig({ rootDir, useTypeScript }); | ||
|
||
const packages = await addDevDependencies(useTypeScript); | ||
|
||
const isYarn = detectYarn(); | ||
logInstallDependencies(packages, isYarn); | ||
installDependencies(isYarn); | ||
} catch (error) { | ||
logError(error); | ||
process.exit(1); | ||
} | ||
})(); | ||
export { promptOverwrite } from './cli'; |
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,47 @@ | ||
name: qawolf | ||
on: | ||
push: | ||
# test every branch | ||
# edit below if you only want certain branches tested | ||
branches: "*" | ||
# schedule: | ||
# # test on schedule using cron syntax | ||
# - cron: "0 * * * *" # every hour | ||
jobs: | ||
test: | ||
runs-on: ubuntu-18.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-node@v1 | ||
|
||
- uses: microsoft/playwright-github-action@v1 | ||
|
||
- uses: actions/cache@v1 | ||
with: | ||
path: ~/.npm | ||
key: $\{{ runner.os }}-node-$\{{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
$\{{ runner.os }}-node- | ||
- run: npm install | ||
|
||
# - name: Start local server | ||
# run: npm run start & npx wait-on http://localhost:3000 | ||
|
||
- run: npx qawolf test --headless | ||
env: | ||
# configure tests with environment variables | ||
FFMPEG_PATH: /usr/bin/ffmpeg # for recording video | ||
QAW_ARTIFACT_PATH: $\{{ github.workspace }}/artifacts | ||
# you can also use GitHub secrets for environment variables | ||
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets | ||
# LOGIN_PASSWORD: $\{{ secrets.PASSWORD }} | ||
|
||
- name: Upload Artifacts | ||
if: always() | ||
uses: actions/upload-artifact@master | ||
with: | ||
name: qawolf | ||
path: $\{{ github.workspace }}/artifacts |
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,40 @@ | ||
import * as fsExtra from 'fs-extra'; | ||
import * as prompt from '../src/cli'; | ||
|
||
const { promptOverwrite } = prompt; | ||
|
||
jest.mock('fs-extra'); | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
describe('promptOverwrite', () => { | ||
afterAll(() => jest.restoreAllMocks()); | ||
|
||
it('returns true if path does not exist', async () => { | ||
jest.spyOn(fsExtra, 'pathExists').mockReturnValue(false as any); | ||
|
||
const shouldSave = await promptOverwrite('myTest.test.js'); | ||
expect(shouldSave).toBe(true); | ||
}); | ||
|
||
it('returns true if path exists but can overwrite', async () => { | ||
jest.spyOn(fsExtra, 'pathExists').mockReturnValue(true as any); | ||
|
||
jest | ||
.spyOn(prompt, 'promptConfirmOverwrite') | ||
.mockReturnValue(new Promise((resolve) => resolve(true))); | ||
|
||
const shouldSave = await promptOverwrite('myTest.test.js'); | ||
expect(shouldSave).toBe(true); | ||
}); | ||
|
||
it('returns false if path exists and cannot overwrite', async () => { | ||
jest.spyOn(fsExtra, 'pathExists').mockReturnValue(true as any); | ||
jest | ||
.spyOn(prompt, 'promptConfirmOverwrite') | ||
.mockReturnValue(new Promise((resolve) => resolve(false))); | ||
|
||
const shouldSave = await promptOverwrite('myTest.test.js'); | ||
expect(shouldSave).toBe(false); | ||
}); | ||
}); | ||
/* eslint-enable @typescript-eslint/no-explicit-any */ |