@qawolf/cli 0.9.3-alpha.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/README.md +93 -0
- package/dist/cli.js +182181 -0
- package/package.json +80 -38
- package/skills/.gitkeep +0 -0
- package/skills/qawolf-cli/SKILL.md +67 -0
- package/LICENSE.md +0 -12
- package/lib/CreateCodeCLI.d.ts +0 -32
- package/lib/CreateCodeCLI.js +0 -112
- package/lib/CreateCodeCLI.js.map +0 -1
- package/lib/ci.d.ts +0 -3
- package/lib/ci.js +0 -47
- package/lib/ci.js.map +0 -1
- package/lib/howl.d.ts +0 -1
- package/lib/howl.js +0 -19
- package/lib/howl.js.map +0 -1
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -137
- package/lib/index.js.map +0 -1
- package/lib/runJest.d.ts +0 -9
- package/lib/runJest.js +0 -46
- package/lib/runJest.js.map +0 -1
- package/lib/utils.d.ts +0 -3
- package/lib/utils.js +0 -17
- package/lib/utils.js.map +0 -1
- package/src/CreateCodeCLI.ts +0 -143
- package/src/ci.ts +0 -48
- package/src/howl.ts +0 -17
- package/src/index.ts +0 -145
- package/src/runJest.ts +0 -74
- package/src/utils.ts +0 -20
- package/static/azure.hbs +0 -35
- package/static/bitbucket.hbs +0 -14
- package/static/circleci.hbs +0 -51
- package/static/github.hbs +0 -53
- package/static/gitlab.hbs +0 -26
- package/static/jenkins.hbs +0 -32
package/lib/runJest.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const child_process_1 = require("child_process");
|
|
4
|
-
const runCommand = (command, env = {}) => {
|
|
5
|
-
console.log(command + "\n");
|
|
6
|
-
child_process_1.execSync(command, {
|
|
7
|
-
stdio: "inherit",
|
|
8
|
-
env: Object.assign(Object.assign({}, process.env), env)
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
exports.runJest = (args = [], options = {}) => {
|
|
12
|
-
let command = `npx jest`;
|
|
13
|
-
if (!args.some(arg => arg.startsWith("--config"))) {
|
|
14
|
-
command += " --config={}";
|
|
15
|
-
}
|
|
16
|
-
command += ' --preset="@qawolf/jest-plugin"';
|
|
17
|
-
if (options.repl) {
|
|
18
|
-
command += ` --reporters="@qawolf/repl"`;
|
|
19
|
-
}
|
|
20
|
-
const rootDir = options.path || ".qawolf";
|
|
21
|
-
command += ` --rootDir=${rootDir}`;
|
|
22
|
-
const hasTimeout = args.findIndex(a => a.toLowerCase().includes("testtimeout")) > -1;
|
|
23
|
-
if (!hasTimeout) {
|
|
24
|
-
const timeout = options.repl ? "3600000" : "60000";
|
|
25
|
-
command += ` --testTimeout=${timeout}`;
|
|
26
|
-
}
|
|
27
|
-
if (args.length) {
|
|
28
|
-
command += ` ${args.join(" ")}`;
|
|
29
|
-
}
|
|
30
|
-
try {
|
|
31
|
-
if (options.browsers && options.browsers.length) {
|
|
32
|
-
for (let browser of options.browsers) {
|
|
33
|
-
console.log(`Test: ${browser}`);
|
|
34
|
-
runCommand(command, { QAW_BROWSER: browser });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
runCommand(command);
|
|
39
|
-
}
|
|
40
|
-
return 0;
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
return 1;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=runJest.js.map
|
package/lib/runJest.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runJest.js","sourceRoot":"","sources":["../src/runJest.ts"],"names":[],"mappings":";;AACA,iDAAyC;AASzC,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,MAAyB,EAAE,EAAE,EAAE;IAElE,OAAO,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAE5B,wBAAQ,CAAC,OAAO,EAAE;QAChB,KAAK,EAAE,SAAS;QAChB,GAAG,kCACE,OAAO,CAAC,GAAG,GACX,GAAG,CACP;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEW,QAAA,OAAO,GAAG,CAAC,OAAiB,EAAE,EAAE,UAA0B,EAAE,EAAE,EAAE;IAI3E,IAAI,OAAO,GAAG,UAAU,CAAC;IAEzB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE;QAGjD,OAAO,IAAI,cAAc,CAAC;KAC3B;IAED,OAAO,IAAI,iCAAiC,CAAC;IAE7C,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,OAAO,IAAI,6BAA6B,CAAC;KAC1C;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,SAAS,CAAC;IAC1C,OAAO,IAAI,cAAc,OAAO,EAAE,CAAC;IAEnC,MAAM,UAAU,GACd,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAEpE,IAAI,CAAC,UAAU,EAAE;QAGf,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;QACnD,OAAO,IAAI,kBAAkB,OAAO,EAAE,CAAC;KACxC;IAGD,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,OAAO,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;KACjC;IAED,IAAI;QACF,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE;YAC/C,KAAK,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE;gBACpC,OAAO,CAAC,GAAG,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;gBAChC,UAAU,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC;aAC/C;SACF;aAAM;YACL,UAAU,CAAC,OAAO,CAAC,CAAC;SACrB;QAED,OAAO,CAAC,CAAC;KACV;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,CAAC;KACV;AACH,CAAC,CAAC"}
|
package/lib/utils.d.ts
DELETED
package/lib/utils.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const url_1 = require("url");
|
|
4
|
-
exports.omitArgs = (args, argsToOmit) => {
|
|
5
|
-
return args.filter(arg => !argsToOmit.some(skip => arg.startsWith(skip)));
|
|
6
|
-
};
|
|
7
|
-
exports.parseUrl = (urlString) => {
|
|
8
|
-
let url = url_1.parse(urlString);
|
|
9
|
-
if (!url.protocol) {
|
|
10
|
-
url = url_1.parse(`https://${urlString}`);
|
|
11
|
-
}
|
|
12
|
-
if (!url.hostname) {
|
|
13
|
-
throw new Error(`Invalid url ${urlString}`);
|
|
14
|
-
}
|
|
15
|
-
return url;
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAEf,QAAA,QAAQ,GAAG,CAAC,IAAc,EAAE,UAAoB,EAAE,EAAE;IAC/D,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC5E,CAAC,CAAC;AAEW,QAAA,QAAQ,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC5C,IAAI,GAAG,GAAG,WAAK,CAAC,SAAS,CAAC,CAAC;IAG3B,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE;QACjB,GAAG,GAAG,WAAK,CAAC,WAAW,SAAS,EAAE,CAAC,CAAC;KACrC;IAED,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,eAAe,SAAS,EAAE,CAAC,CAAC;KAC7C;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
package/src/CreateCodeCLI.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { BrowserContext, launch } from "@qawolf/browser";
|
|
2
|
-
import { CodeCreator } from "@qawolf/create-code";
|
|
3
|
-
import { repl } from "@qawolf/repl";
|
|
4
|
-
import { prompt } from "inquirer";
|
|
5
|
-
import { bold } from "kleur";
|
|
6
|
-
import { join, relative } from "path";
|
|
7
|
-
import { Url } from "url";
|
|
8
|
-
|
|
9
|
-
type CreateOptions = {
|
|
10
|
-
codePath?: string;
|
|
11
|
-
debug?: boolean;
|
|
12
|
-
device?: string;
|
|
13
|
-
isTest?: boolean;
|
|
14
|
-
name: string;
|
|
15
|
-
path?: string;
|
|
16
|
-
selectorPath?: string;
|
|
17
|
-
url: Url;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type ConstructOptions = {
|
|
21
|
-
context: BrowserContext;
|
|
22
|
-
codePath: string;
|
|
23
|
-
codeCreator: CodeCreator;
|
|
24
|
-
debug: boolean;
|
|
25
|
-
isTest: boolean;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export class CreateCodeCLI {
|
|
29
|
-
private _codePath: string;
|
|
30
|
-
private _codeCreator: CodeCreator;
|
|
31
|
-
private _context: BrowserContext;
|
|
32
|
-
private _debug: boolean;
|
|
33
|
-
private _isTest: boolean;
|
|
34
|
-
|
|
35
|
-
protected constructor(options: ConstructOptions) {
|
|
36
|
-
this._codePath = options.codePath;
|
|
37
|
-
this._codeCreator = options.codeCreator;
|
|
38
|
-
this._context = options.context;
|
|
39
|
-
this._debug = options.debug;
|
|
40
|
-
this._isTest = options.isTest;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
static async start(options: CreateOptions) {
|
|
44
|
-
try {
|
|
45
|
-
const contextPromise = launch({
|
|
46
|
-
device: options.device,
|
|
47
|
-
shouldRecordEvents: true,
|
|
48
|
-
timeout: 0
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const rootPath = options.path || `${process.cwd()}/.qawolf`;
|
|
52
|
-
|
|
53
|
-
let codePath = options.codePath;
|
|
54
|
-
if (!codePath) {
|
|
55
|
-
codePath = options.isTest
|
|
56
|
-
? join(rootPath, "tests", `${options.name}.test.js`)
|
|
57
|
-
: join(rootPath, "scripts", `${options.name}.js`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const selectorPath =
|
|
61
|
-
options.selectorPath ||
|
|
62
|
-
join(rootPath, "selectors", `${options.name}.json`);
|
|
63
|
-
|
|
64
|
-
const codeCreator = await CodeCreator.start({
|
|
65
|
-
codePath,
|
|
66
|
-
device: options.device,
|
|
67
|
-
isTest: options.isTest,
|
|
68
|
-
name: options.name,
|
|
69
|
-
selectorPath,
|
|
70
|
-
url: options.url.href!
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const context = await contextPromise;
|
|
74
|
-
|
|
75
|
-
context.qawolf().goto(options.url.href!);
|
|
76
|
-
|
|
77
|
-
context.qawolf().on("recorded_event", event => {
|
|
78
|
-
codeCreator.pushEvent(event);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
codeCreator.startPolling();
|
|
82
|
-
|
|
83
|
-
const command = new CreateCodeCLI({
|
|
84
|
-
codePath,
|
|
85
|
-
codeCreator,
|
|
86
|
-
context,
|
|
87
|
-
debug: !!options.debug,
|
|
88
|
-
isTest: !!options.isTest
|
|
89
|
-
});
|
|
90
|
-
await command._prompt();
|
|
91
|
-
} catch (e) {
|
|
92
|
-
if (e.message === "Cannot find selector file to update") {
|
|
93
|
-
logNoSelectors();
|
|
94
|
-
} else {
|
|
95
|
-
throw e;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
process.exit(1);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
protected async _prompt() {
|
|
103
|
-
const { choice } = await prompt<{ choice: string }>([
|
|
104
|
-
{
|
|
105
|
-
choices: [
|
|
106
|
-
"💾 Save and exit",
|
|
107
|
-
"🖥️ Open REPL to run code",
|
|
108
|
-
"🗑️ Discard and exit"
|
|
109
|
-
],
|
|
110
|
-
message: `Edit your ${this._isTest ? "test" : "script"} at: ${relative(
|
|
111
|
-
process.cwd(),
|
|
112
|
-
this._codePath
|
|
113
|
-
)}`,
|
|
114
|
-
name: "choice",
|
|
115
|
-
type: "list"
|
|
116
|
-
}
|
|
117
|
-
]);
|
|
118
|
-
|
|
119
|
-
if (choice.includes("REPL")) {
|
|
120
|
-
await repl();
|
|
121
|
-
await this._prompt();
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
await this._context.close();
|
|
126
|
-
|
|
127
|
-
if (choice.includes("Save")) {
|
|
128
|
-
await this._codeCreator.save({ debug: this._debug });
|
|
129
|
-
} else {
|
|
130
|
-
await this._codeCreator.discard();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
process.exit(0);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const logNoSelectors = () => {
|
|
138
|
-
console.log(bold().red("Cannot find selectors to update"));
|
|
139
|
-
console.log(
|
|
140
|
-
bold().blue("Specify them with:"),
|
|
141
|
-
"npx qawolf create --selectors /path/to/selectors.json"
|
|
142
|
-
);
|
|
143
|
-
};
|
package/src/ci.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { outputFile, pathExists, readFileSync } from "fs-extra";
|
|
2
|
-
import { compile } from "handlebars";
|
|
3
|
-
import { prompt } from "inquirer";
|
|
4
|
-
import path from "path";
|
|
5
|
-
const { version } = require("../package");
|
|
6
|
-
|
|
7
|
-
type CiProvider =
|
|
8
|
-
| "azure"
|
|
9
|
-
| "bitbucket"
|
|
10
|
-
| "circleci"
|
|
11
|
-
| "github"
|
|
12
|
-
| "gitlab"
|
|
13
|
-
| "jenkins";
|
|
14
|
-
|
|
15
|
-
const paths = {
|
|
16
|
-
azure: "azure-pipelines.yml",
|
|
17
|
-
bitbucket: "bitbucket-pipelines.yml",
|
|
18
|
-
circleci: ".circleci/config.yml",
|
|
19
|
-
github: ".github/workflows/qawolf.yml",
|
|
20
|
-
gitlab: ".gitlab-ci.yml",
|
|
21
|
-
jenkins: "Jenkinsfile"
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const saveCiTemplate = async (provider: CiProvider): Promise<void> => {
|
|
25
|
-
const providerPath = paths[provider];
|
|
26
|
-
|
|
27
|
-
const outputPath = path.join(process.cwd(), providerPath);
|
|
28
|
-
|
|
29
|
-
if (await pathExists(outputPath)) {
|
|
30
|
-
const { overwrite } = await prompt<{ overwrite: boolean }>([
|
|
31
|
-
{
|
|
32
|
-
message: `"${outputPath}" already exists, overwrite it?`,
|
|
33
|
-
name: "overwrite",
|
|
34
|
-
type: "confirm"
|
|
35
|
-
}
|
|
36
|
-
]);
|
|
37
|
-
if (!overwrite) return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const ciTemplate = compile(
|
|
41
|
-
readFileSync(path.resolve(__dirname, `../static/${provider}.hbs`), "utf8")
|
|
42
|
-
);
|
|
43
|
-
const ci = ciTemplate({ version });
|
|
44
|
-
|
|
45
|
-
await outputFile(outputPath, ci, "utf8");
|
|
46
|
-
|
|
47
|
-
console.log(`Saved ${provider} template to ${outputPath}`);
|
|
48
|
-
};
|
package/src/howl.ts
DELETED
package/src/index.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { logger } from "@qawolf/logger";
|
|
4
|
-
import { BrowserType } from "@qawolf/types";
|
|
5
|
-
import program from "commander";
|
|
6
|
-
import { yellow } from "kleur";
|
|
7
|
-
import { saveCiTemplate } from "./ci";
|
|
8
|
-
import { CreateCodeCLI } from "./CreateCodeCLI";
|
|
9
|
-
import { howl } from "./howl";
|
|
10
|
-
import { runJest } from "./runJest";
|
|
11
|
-
import { omitArgs, parseUrl } from "./utils";
|
|
12
|
-
const pkg = require("../package");
|
|
13
|
-
|
|
14
|
-
program.usage("<command> [options]").version(pkg.version);
|
|
15
|
-
|
|
16
|
-
program
|
|
17
|
-
.command("create <url> [name]")
|
|
18
|
-
.option("--code-path <codePath>", "path to save the code file")
|
|
19
|
-
.option("--debug", "save events and workflow json for debugging")
|
|
20
|
-
.option("-d, --device <device>", "emulate using a playwright.device")
|
|
21
|
-
.option("-p, --path <path>", "path to save the files")
|
|
22
|
-
.option("-s, --script", "create a script instead of a test")
|
|
23
|
-
.option("--selector-path <selectorPath>", "path to save the selector file")
|
|
24
|
-
.description("create a test from browser actions")
|
|
25
|
-
.action(async (urlArgument, optionalName, cmd) => {
|
|
26
|
-
const url = parseUrl(urlArgument);
|
|
27
|
-
logger.verbose(`create "${url.href}"`);
|
|
28
|
-
|
|
29
|
-
const name = optionalName || url.hostname!.replace(/\..*/g, "");
|
|
30
|
-
|
|
31
|
-
await CreateCodeCLI.start({
|
|
32
|
-
codePath: cmd.codePath,
|
|
33
|
-
debug: cmd.debug,
|
|
34
|
-
device: cmd.device,
|
|
35
|
-
name,
|
|
36
|
-
isTest: !cmd.script,
|
|
37
|
-
path: cmd.path,
|
|
38
|
-
selectorPath: cmd.selectorPath,
|
|
39
|
-
url
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
program
|
|
44
|
-
.command("test")
|
|
45
|
-
.option("-p, --path <path>", "path to test code")
|
|
46
|
-
.option("--all-browsers", "run tests on chromium, firefox, and webkit")
|
|
47
|
-
.option("--chromium", "run tests on chromium")
|
|
48
|
-
.option("--firefox", "run tests on firefox")
|
|
49
|
-
.option("--repl", "open a REPL when repl() is called")
|
|
50
|
-
.option("--webkit", "run tests on webkit")
|
|
51
|
-
.description("run a test with Jest")
|
|
52
|
-
.allowUnknownOption(true)
|
|
53
|
-
.action((cmd = {}) => {
|
|
54
|
-
const args = omitArgs(process.argv.slice(3), [
|
|
55
|
-
"--all-browsers",
|
|
56
|
-
"--chromium",
|
|
57
|
-
"--firefox",
|
|
58
|
-
"-p",
|
|
59
|
-
"--path",
|
|
60
|
-
"--repl",
|
|
61
|
-
"--webkit"
|
|
62
|
-
]);
|
|
63
|
-
|
|
64
|
-
let browsers: BrowserType[] = [];
|
|
65
|
-
|
|
66
|
-
if (cmd.allBrowsers || cmd.chromium) {
|
|
67
|
-
browsers.push("chromium");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (cmd.allBrowsers || cmd.firefox) {
|
|
71
|
-
browsers.push("firefox");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (cmd.allBrowsers || cmd.webkit) {
|
|
75
|
-
browsers.push("webkit");
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const code = runJest(args, {
|
|
79
|
-
browsers,
|
|
80
|
-
path: cmd.path,
|
|
81
|
-
repl: !!cmd.repl
|
|
82
|
-
});
|
|
83
|
-
process.exit(code);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
program
|
|
87
|
-
.command("azure")
|
|
88
|
-
.description("set up an Azure Pipeline")
|
|
89
|
-
.action(async () => {
|
|
90
|
-
await saveCiTemplate("azure");
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
program
|
|
94
|
-
.command("bitbucket")
|
|
95
|
-
.description("set up an Bitbucket Pipeline")
|
|
96
|
-
.action(async () => {
|
|
97
|
-
await saveCiTemplate("bitbucket");
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
program
|
|
101
|
-
.command("circleci")
|
|
102
|
-
.description("set up CircleCI")
|
|
103
|
-
.action(async () => {
|
|
104
|
-
await saveCiTemplate("circleci");
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
program
|
|
108
|
-
.command("github")
|
|
109
|
-
.description("set up a GitHub Action")
|
|
110
|
-
.action(async () => {
|
|
111
|
-
await saveCiTemplate("github");
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
program
|
|
115
|
-
.command("gitlab")
|
|
116
|
-
.description("set up GitLab CI/CD")
|
|
117
|
-
.action(async () => {
|
|
118
|
-
await saveCiTemplate("gitlab");
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
program
|
|
122
|
-
.command("howl")
|
|
123
|
-
.description("🐺")
|
|
124
|
-
.action(howl);
|
|
125
|
-
|
|
126
|
-
program
|
|
127
|
-
.command("jenkins")
|
|
128
|
-
.description("set up Jenkins")
|
|
129
|
-
.action(async () => {
|
|
130
|
-
await saveCiTemplate("jenkins");
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
program.arguments("<command>").action(cmd => {
|
|
134
|
-
console.log(yellow(`Invalid command "${cmd}"\n`));
|
|
135
|
-
program.help();
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
program.allowUnknownOption(false);
|
|
139
|
-
|
|
140
|
-
program.parse(process.argv);
|
|
141
|
-
|
|
142
|
-
if (!process.argv.slice(2).length) {
|
|
143
|
-
console.log("\n");
|
|
144
|
-
program.outputHelp();
|
|
145
|
-
}
|
package/src/runJest.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { BrowserType } from "@qawolf/types";
|
|
2
|
-
import { execSync } from "child_process";
|
|
3
|
-
|
|
4
|
-
type RunJestOptions = {
|
|
5
|
-
browsers?: BrowserType[];
|
|
6
|
-
config?: string;
|
|
7
|
-
path?: string;
|
|
8
|
-
repl?: boolean;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const runCommand = (command: string, env: NodeJS.ProcessEnv = {}) => {
|
|
12
|
-
// log the command we run to make it clear this is an alias for npx jest
|
|
13
|
-
console.log(command + "\n");
|
|
14
|
-
|
|
15
|
-
execSync(command, {
|
|
16
|
-
stdio: "inherit",
|
|
17
|
-
env: {
|
|
18
|
-
...process.env,
|
|
19
|
-
...env
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const runJest = (args: string[] = [], options: RunJestOptions = {}) => {
|
|
25
|
-
/**
|
|
26
|
-
* Returns exit code. 0 for success, 1 for failed.
|
|
27
|
-
*/
|
|
28
|
-
let command = `npx jest`;
|
|
29
|
-
|
|
30
|
-
if (!args.some(arg => arg.startsWith("--config"))) {
|
|
31
|
-
// prevent using the local jest config
|
|
32
|
-
// unless config is passed
|
|
33
|
-
command += " --config={}";
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
command += ' --preset="@qawolf/jest-plugin"';
|
|
37
|
-
|
|
38
|
-
if (options.repl) {
|
|
39
|
-
command += ` --reporters="@qawolf/repl"`;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const rootDir = options.path || ".qawolf";
|
|
43
|
-
command += ` --rootDir=${rootDir}`;
|
|
44
|
-
|
|
45
|
-
const hasTimeout =
|
|
46
|
-
args.findIndex(a => a.toLowerCase().includes("testtimeout")) > -1;
|
|
47
|
-
|
|
48
|
-
if (!hasTimeout) {
|
|
49
|
-
// timeout after 1 hour for repl
|
|
50
|
-
// timeout after 1 minute otherwise
|
|
51
|
-
const timeout = options.repl ? "3600000" : "60000";
|
|
52
|
-
command += ` --testTimeout=${timeout}`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// pass through other arguments to jest
|
|
56
|
-
if (args.length) {
|
|
57
|
-
command += ` ${args.join(" ")}`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
if (options.browsers && options.browsers.length) {
|
|
62
|
-
for (let browser of options.browsers) {
|
|
63
|
-
console.log(`Test: ${browser}`);
|
|
64
|
-
runCommand(command, { QAW_BROWSER: browser });
|
|
65
|
-
}
|
|
66
|
-
} else {
|
|
67
|
-
runCommand(command);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return 0;
|
|
71
|
-
} catch (e) {
|
|
72
|
-
return 1;
|
|
73
|
-
}
|
|
74
|
-
};
|
package/src/utils.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { parse } from "url";
|
|
2
|
-
|
|
3
|
-
export const omitArgs = (args: string[], argsToOmit: string[]) => {
|
|
4
|
-
return args.filter(arg => !argsToOmit.some(skip => arg.startsWith(skip)));
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const parseUrl = (urlString: string) => {
|
|
8
|
-
let url = parse(urlString);
|
|
9
|
-
|
|
10
|
-
// prefix w/ https if a protocol is not provided
|
|
11
|
-
if (!url.protocol) {
|
|
12
|
-
url = parse(`https://${urlString}`);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (!url.hostname) {
|
|
16
|
-
throw new Error(`Invalid url ${urlString}`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return url;
|
|
20
|
-
};
|
package/static/azure.hbs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# configure the pipeline to run based on different triggers
|
|
2
|
-
# see https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#triggers
|
|
3
|
-
pool:
|
|
4
|
-
vmImage: "ubuntu-18.04"
|
|
5
|
-
|
|
6
|
-
steps:
|
|
7
|
-
- task: NodeTool@0
|
|
8
|
-
inputs:
|
|
9
|
-
versionSpec: "12.x"
|
|
10
|
-
|
|
11
|
-
- script: |
|
|
12
|
-
sudo apt update
|
|
13
|
-
# chromium dependencies
|
|
14
|
-
sudo apt-get install libgbm1
|
|
15
|
-
# webkit dependencies
|
|
16
|
-
sudo apt-get install libwoff1 libopus0 libwebp6 libwebpdemux2 libenchant1c2a libgudev-1.0-0 libsecret-1-0 libhyphen0 libgdk-pixbuf2.0-0 libegl1 libgles2 libevent-2.1-6 libnotify4 libvpx5 libxslt1.1
|
|
17
|
-
displayName: "Install browser dependencies"
|
|
18
|
-
|
|
19
|
-
- script: npm install
|
|
20
|
-
|
|
21
|
-
# # Start local server
|
|
22
|
-
# - script: npm run start & npx wait-on http://localhost:3000
|
|
23
|
-
|
|
24
|
-
- script: npx qawolf test
|
|
25
|
-
env:
|
|
26
|
-
QAW_ARTIFACT_PATH: $(System.DefaultWorkingDirectory)/artifacts
|
|
27
|
-
# configure tests with environment variables
|
|
28
|
-
# QAW_SLEEP_MS: 0
|
|
29
|
-
# you can also use secret environment variables
|
|
30
|
-
# https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#secret-variables
|
|
31
|
-
# LOGIN_PASSWORD: $(SECRET_PASSWORD)
|
|
32
|
-
|
|
33
|
-
- publish: $(System.DefaultWorkingDirectory)/artifacts
|
|
34
|
-
artifact: artifacts
|
|
35
|
-
condition: always()
|
package/static/bitbucket.hbs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
pipelines:
|
|
2
|
-
default:
|
|
3
|
-
- step:
|
|
4
|
-
name: QA Wolf Tests
|
|
5
|
-
image: qawolf/qawolf:v{{{version}}}
|
|
6
|
-
caches:
|
|
7
|
-
- node
|
|
8
|
-
script:
|
|
9
|
-
- npm install
|
|
10
|
-
## Start local server
|
|
11
|
-
# - npm run start & npx wait-on http://localhost:3000
|
|
12
|
-
- QAW_ARTIFACT_PATH=artifacts npx qawolf test --all-browsers
|
|
13
|
-
artifacts:
|
|
14
|
-
- artifacts/**
|
package/static/circleci.hbs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
version: 2
|
|
2
|
-
jobs:
|
|
3
|
-
build:
|
|
4
|
-
docker:
|
|
5
|
-
- image: qawolf/qawolf:v{{{version}}}
|
|
6
|
-
steps:
|
|
7
|
-
- checkout
|
|
8
|
-
|
|
9
|
-
- restore_cache:
|
|
10
|
-
key: dependency-cache-\{{ checksum "package-lock.json" }}
|
|
11
|
-
|
|
12
|
-
- run:
|
|
13
|
-
command: npm install
|
|
14
|
-
|
|
15
|
-
- save_cache:
|
|
16
|
-
key: dependency-cache-\{{ checksum "package-lock.json" }}
|
|
17
|
-
paths:
|
|
18
|
-
- ./node_modules
|
|
19
|
-
|
|
20
|
-
- run:
|
|
21
|
-
command: |
|
|
22
|
-
# # Start local server
|
|
23
|
-
# npm run start &
|
|
24
|
-
# npx wait-on http://localhost:3000
|
|
25
|
-
npx qawolf test
|
|
26
|
-
environment:
|
|
27
|
-
QAW_ARTIFACT_PATH: /tmp/artifacts
|
|
28
|
-
# # configure tests with environment variables
|
|
29
|
-
# QAW_SLEEP_MS: 0
|
|
30
|
-
# # you can also use secret environment variables
|
|
31
|
-
# # https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project
|
|
32
|
-
# LOGIN_PASSWORD: ${SECRET_PASSWORD}
|
|
33
|
-
|
|
34
|
-
- store_artifacts:
|
|
35
|
-
path: /tmp/artifacts
|
|
36
|
-
|
|
37
|
-
# # example for running on a schedule, edit to suit your use case
|
|
38
|
-
# # documentation: https://circleci.com/docs/2.0/configuration-reference/#schedule
|
|
39
|
-
# workflows:
|
|
40
|
-
# version: 2
|
|
41
|
-
# on_schedule:
|
|
42
|
-
# jobs:
|
|
43
|
-
# - build
|
|
44
|
-
# triggers:
|
|
45
|
-
# - schedule:
|
|
46
|
-
# # test on schedule using cron syntax
|
|
47
|
-
# cron: "0 * * * *" # every hour
|
|
48
|
-
# filters:
|
|
49
|
-
# branches:
|
|
50
|
-
# only:
|
|
51
|
-
# - master
|
package/static/github.hbs
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
name: qawolf
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
# test every branch
|
|
5
|
-
# edit below if you only want certain branches tested
|
|
6
|
-
branches: "*"
|
|
7
|
-
# schedule:
|
|
8
|
-
# # test on schedule using cron syntax
|
|
9
|
-
# - cron: "0 * * * *" # every hour
|
|
10
|
-
jobs:
|
|
11
|
-
test:
|
|
12
|
-
runs-on: ubuntu-18.04
|
|
13
|
-
|
|
14
|
-
steps:
|
|
15
|
-
- name: Install dependencies
|
|
16
|
-
run: |
|
|
17
|
-
sudo apt update
|
|
18
|
-
# chromium dependencies
|
|
19
|
-
sudo apt-get install libgbm1
|
|
20
|
-
# webkit dependencies
|
|
21
|
-
sudo apt-get install libwoff1 libopus0 libwebp6 libwebpdemux2 libenchant1c2a libgudev-1.0-0 libsecret-1-0 libhyphen0 libgdk-pixbuf2.0-0 libegl1 libgles2 libevent-2.1-6 libnotify4 libvpx5 libxslt1.1
|
|
22
|
-
|
|
23
|
-
- uses: actions/checkout@v2
|
|
24
|
-
|
|
25
|
-
- uses: actions/setup-node@v1
|
|
26
|
-
|
|
27
|
-
- uses: actions/cache@v1
|
|
28
|
-
with:
|
|
29
|
-
path: ~/.npm
|
|
30
|
-
key: $\{{ runner.os }}-node-$\{{ hashFiles('**/package-lock.json') }}
|
|
31
|
-
restore-keys: |
|
|
32
|
-
$\{{ runner.os }}-node-
|
|
33
|
-
|
|
34
|
-
- run: npm install
|
|
35
|
-
|
|
36
|
-
# - name: Start local server
|
|
37
|
-
# run: npm run start & npx wait-on http://localhost:3000
|
|
38
|
-
|
|
39
|
-
- run: npx qawolf test
|
|
40
|
-
env:
|
|
41
|
-
QAW_ARTIFACT_PATH: $\{{ github.workspace }}/artifacts
|
|
42
|
-
# # configure tests with environment variables
|
|
43
|
-
# QAW_SLEEP_MS: 0
|
|
44
|
-
# # you can also use GitHub secrets for environment variables
|
|
45
|
-
# # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets
|
|
46
|
-
# LOGIN_PASSWORD: $\{{ secrets.PASSWORD }}
|
|
47
|
-
|
|
48
|
-
- name: Upload Artifacts
|
|
49
|
-
if: always()
|
|
50
|
-
uses: actions/upload-artifact@master
|
|
51
|
-
with:
|
|
52
|
-
name: qawolf
|
|
53
|
-
path: $\{{ github.workspace }}/artifacts
|