-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a unit framework testing infrastructure (#99)
* test(create-webstone-app): write unit tests for the `create-webstone-app` package * test: run tests for changed packages in a pre-commit git hook * ci: add a tests workflow * chore: remove the package-lock.json file at the root
- Loading branch information
1 parent
131b954
commit 0b94911
Showing
20 changed files
with
719 additions
and
2,389 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,6 @@ | ||
--- | ||
"@webstone/cli": minor | ||
"create-webstone-app": minor | ||
--- | ||
|
||
Write unit tests for the `create-webstone-app` package. |
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,25 @@ | ||
name: Tests | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
tests: | ||
name: Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@master | ||
|
||
- name: Setup Node.js 14.x | ||
uses: actions/setup-node@master | ||
with: | ||
node-version: 14.x | ||
|
||
- name: Install pnpm globally | ||
run: npm install -g pnpm | ||
|
||
- name: Install Dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Run all tests | ||
run: pnpm test |
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,2 +1,4 @@ | ||
coverage | ||
node_modules | ||
package-lock.json | ||
packages/**/dist |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -9,4 +9,4 @@ const command: GluegunCommand = { | |
}, | ||
}; | ||
|
||
module.exports = command; | ||
export default command; |
Empty file.
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
Empty file.
Empty file.
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,22 @@ | ||
import { | ||
createAppDir, | ||
copyTemplate, | ||
displayNextSteps, | ||
displayWelcome, | ||
installDependencies, | ||
installWebApp, | ||
} from "./helpers"; | ||
|
||
const pipe = (...functions: ((input?: any) => Promise<any>)[]) => ( | ||
input?: any | ||
) => | ||
functions.reduce((chain, func) => chain.then(func), Promise.resolve(input)); | ||
|
||
pipe( | ||
displayWelcome, | ||
createAppDir, | ||
copyTemplate, | ||
installWebApp, | ||
installDependencies, | ||
displayNextSteps | ||
)(); |
25 changes: 25 additions & 0 deletions
25
packages/create-webstone-app/tests/helpers/copy-template.ts
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,25 @@ | ||
import fs from "fs-extra"; | ||
import path from "path"; | ||
import sinon from "sinon"; | ||
import { test } from "uvu"; | ||
import * as assert from "uvu/assert"; | ||
import { copyTemplate } from "../../src/helpers"; | ||
|
||
test.after.each(() => { | ||
sinon.restore(); | ||
}); | ||
|
||
test("copy the template to the correct location", async () => { | ||
const fakePathJoin = sinon.fake.returns("../template"); | ||
sinon.replace(path, "join", fakePathJoin); | ||
|
||
const fakeFsCopySync = sinon.fake(); | ||
sinon.replace(fs, "copySync", fakeFsCopySync); | ||
|
||
const appDir = await copyTemplate("test-dir"); | ||
assert.is(appDir, "test-dir"); | ||
assert.is(fakeFsCopySync.firstCall.firstArg, "../template"); | ||
assert.is(fakeFsCopySync.firstCall.lastArg, "test-dir"); | ||
}); | ||
|
||
test.run(); |
Oops, something went wrong.