-
Notifications
You must be signed in to change notification settings - Fork 3
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 #25 from tuanthanh2067/add-e2e-test
Added e2e test
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`end-to-end integration prints help message when --help option is passed 1`] = ` | ||
"Usage: index.js --input <filename> [-s <css-link>] [-l <lang-code>] | ||
Options: | ||
-i, --input .txt or .md file name [array] | ||
-c, --config configuration file [array] [default: \\"\\"] | ||
-a, --assets path to assets folder [array] [default: \\"\\"] | ||
-s, --stylesheet css link [string] | ||
-l, --lang language used in HTML [string] | ||
-v, --version Show version number [boolean] | ||
-h, --help Show help [boolean]" | ||
`; | ||
exports[`end-to-end integration prints version when --version option is passed 1`] = `"ssg-cli 1.0.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const run = require("./run"); | ||
|
||
describe("end-to-end integration", () => { | ||
test("prints help message when --help option is passed", async () => { | ||
const { stderr, stdout, exitCode } = await run("--help"); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stdout).toMatchSnapshot(); | ||
expect(stderr).toEqual(""); | ||
}); | ||
|
||
test("prints version when --version option is passed", async () => { | ||
const { stderr, stdout, exitCode } = await run("--version"); | ||
|
||
expect(exitCode).toBe(0); | ||
expect(stdout).toMatchSnapshot(); | ||
expect(stderr).toEqual(""); | ||
}); | ||
}); |
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,12 @@ | ||
const execa = require("execa"); | ||
|
||
async function run(...args) { | ||
try { | ||
const results = await execa.node("./bin/index.js", args); | ||
return results; | ||
} catch (err) { | ||
return err; | ||
} | ||
} | ||
|
||
module.exports = run; |