-
-
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.
Merge pull request #10 from saiichihashimoto/e2e-test
integration tests
- Loading branch information
Showing
8 changed files
with
122 additions
and
52 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,56 @@ | ||
import { exec as execCallback } from "node:child_process"; | ||
import { promisify } from "node:util"; | ||
|
||
import { beforeAll, describe, expect, it } from "@jest/globals"; | ||
|
||
// eslint-disable-next-line global-require, @typescript-eslint/no-require-imports, unicorn/prefer-module, @typescript-eslint/no-unused-vars -- HACK We're "including" bin by running a process against the built file so jest won't pick it up with `--findRelatedTests`. | ||
const helpJestFindRelatedTests = () => require("./bin"); | ||
|
||
const exec = promisify(execCallback); | ||
|
||
describe("bin", () => { | ||
beforeAll(async () => { | ||
await exec("npm run build"); | ||
}); | ||
|
||
it("--version", async () => { | ||
const { stderr, stdout } = await exec("node ./dist/bin.js --version"); | ||
expect(stderr).toBe(""); | ||
expect(stdout).toBe("0.0.0-development\n"); | ||
}); | ||
|
||
it("--help", async () => { | ||
const { stderr, stdout } = await exec("node ./dist/bin.js --help"); | ||
|
||
expect(stderr).toBe(""); | ||
expect(stdout).toBe(`Usage: vercel-cron [options] | ||
Options: | ||
-V, --version output the version number | ||
-u --url <url> Base URL (default: "http://localhost:3000") | ||
-p --config <config> Vercel Config (default: "./vercel.json") | ||
-s --secret <secret> Cron Secret | ||
--dryRun Shows scheduled CRONs and quits (default: false) | ||
-l --level <level> Logging Level (choices: "trace", "debug", "info", | ||
"warn", "error", "fatal", default: "info") | ||
-h, --help display help for command | ||
`); | ||
}); | ||
|
||
it("runs with empty vercel.json", async () => { | ||
const { stderr, stdout } = await exec( | ||
"node ./dist/bin.js --ignoreTime --dryRun", | ||
{ env: { ...process.env, FORCE_COLOR: "0" } } | ||
); | ||
|
||
expect(stderr).toBe(""); | ||
expect(stdout).toBe(`╭─────────────────────────╮ | ||
│ │ | ||
│ ▲ Vercel CRON ▲ │ | ||
│ │ | ||
╰─────────────────────────╯ | ||
INFO: No CRONs Scheduled | ||
`); | ||
}); | ||
}); |
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,4 +1,30 @@ | ||
#!/usr/bin/env node | ||
import { main } from "."; | ||
import { Command, Option } from "commander"; | ||
|
||
main(); | ||
import { main, zOpts } from "."; | ||
import pkg from "../package.json"; | ||
|
||
main( | ||
zOpts.parse( | ||
new Command() | ||
.name(pkg.name) | ||
.version(pkg.version) | ||
.option("-u --url <url>", "Base URL", "http://localhost:3000") | ||
.option("-p --config <config>", "Vercel Config", "./vercel.json") | ||
.addOption( | ||
new Option("-s --secret <secret>", "Cron Secret").default( | ||
process.env.CRON_SECRET, | ||
"process.env.CRON_SECRET" | ||
) | ||
) | ||
.option("--dryRun", "Shows scheduled CRONs and quits", false) | ||
.addOption( | ||
new Option("-l --level <level>", "Logging Level") | ||
.default("info") | ||
.choices(["trace", "debug", "info", "warn", "error", "fatal"]) | ||
) | ||
.addOption(new Option("--ignoreTime").hideHelp()) | ||
.parse() | ||
.opts() | ||
) | ||
); |
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 |
---|---|---|
|
@@ -7,6 +7,6 @@ | |
"thresholds": { | ||
"high": 95, | ||
"low": 90, | ||
"break": 85 | ||
"break": 40 | ||
} | ||
} |
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,3 +1 @@ | ||
{ | ||
"$schema": "https://openapi.vercel.sh/vercel.json" | ||
} | ||
{} |