Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit 9d4b556

Browse files
authored
Merge pull request #11 from nteract/testing
improve testing, cleanup
2 parents 37d566e + 52ec829 commit 9d4b556

File tree

7 files changed

+2451
-39
lines changed

7 files changed

+2451
-39
lines changed

.circleci/config.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,15 @@ jobs:
1919
keys:
2020
- yarn-packages-{{ checksum "yarn.lock" }}
2121
- yarn-packages-
22-
23-
- run: sudo npm i -g
22+
- run:
23+
name: Install Dependencies
24+
command: yarn
2425

2526
- save_cache:
2627
name: Save Yarn Package Cache
2728
key: yarn-packages-{{ checksum "yarn.lock" }}
2829
paths:
2930
- ~/.cache/yarn
30-
31-
- run:
32-
name: Create an nteract app
33-
command: create-nteract-app snow-leopard
3431

3532
- run:
3633
name: Run tests

.gitignore

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
# parcel-bundler cache (https://parceljs.org/)
61+
.cache
62+
63+
# next.js build output
64+
.next
65+
66+
# nuxt.js build output
67+
.nuxt
68+
69+
# vuepress build output
70+
.vuepress/dist
71+
72+
# Serverless directories
73+
.serverless

__tests__/index-spec.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const fs = require("fs");
22

3-
const checkFile = file => {
4-
if (fs.existsSync(file)) {
5-
console.log(`Success! \n${file} exists!\n`);
6-
} else {
7-
console.log(`Failure! \n${file} does not exist!\n`);
8-
}
9-
};
10-
11-
checkFile("snow-leopard");
12-
checkFile("snow-leopard/pages/index.js");
13-
checkFile("snow-leopard/components/code-area.js");
3+
describe("it checks that the project was create successfully", () => {
4+
it("checks that the project was initiated", () => {
5+
expect(fs.existsSync("snow-leopard/package.json")).toBe(true);
6+
});
7+
it("checks that the project template was created", () => {
8+
expect(fs.existsSync("snow-leopard/components/")).toBe(true);
9+
});
10+
it("checks that the project template was created", () => {
11+
expect(fs.existsSync("snow-leopard/pages/index.js")).toBe(true);
12+
});
13+
});

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"url": "https://github.com/alexandercbooth/create-nteract-app.git"
88
},
99
"scripts": {
10-
"test": "node __tests__/index-spec.js"
10+
"dev": "CNA_ENV=DEV node src/index.js",
11+
"test": "CNA_ENV=DEV yarn dev snow-leopard && jest"
1112
},
1213
"author": "Alexander C. Booth <[email protected]>",
1314
"license": "MIT",
@@ -34,6 +35,7 @@
3435
},
3536
"devDependencies": {
3637
"husky": "^1.0.0-rc.13",
38+
"jest": "^23.5.0",
3739
"lint-staged": "^7.2.0",
3840
"prettier": "1.14.2"
3941
}

scripts/test-setup.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
var { configure } = require("enzyme");
2+
var Adapter = require("enzyme-adapter-react-16");
3+
4+
configure({ adapter: new Adapter() });

src/create-nteract-app.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,19 @@ function run(root, appName, version, verbose, originalDirectory, template) {
122122
return install(root, useYarn, allDependencies, verbose)
123123
.then(() => packageName)
124124
.then(packageName => {
125-
const ownPath = path.join(
126-
nodePath.split("\n")[0],
127-
"lib/node_modules",
128-
packageJson.name
129-
);
125+
const templatePath =
126+
process.env.CNA_ENV === "DEV"
127+
? path.join("../src", "template")
128+
: path.join(
129+
path.join(
130+
nodePath.split("\n")[0],
131+
"lib/node_modules",
132+
packageJson.name
133+
),
134+
"src",
135+
"template"
136+
);
130137
const appPath = process.cwd();
131-
const templatePath = path.join(ownPath, "src", "template");
132138
const appDefaultPage = path.join(templatePath, "pages/index.js");
133139

134140
if (fs.existsSync(templatePath)) {

0 commit comments

Comments
 (0)