Skip to content

Commit

Permalink
test: adjust test structure
Browse files Browse the repository at this point in the history
- Put tests in ./src/**/*.{spec,e2e}.ts instead of ./test
- Use config blocks instead of inline npm script commands
  • Loading branch information
yangchristian committed Jul 11, 2017
1 parent 3f6df3d commit c994174
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Crosslytics [![Build Status](https://travis-ci.org/CrossLead/crosslytics.svg?branch=master)](https://travis-ci.org/CrossLead/crosslytics.svg?branch=master)
# Crosslytics
[![Build Status](https://travis-ci.org/CrossLead/crosslytics.svg?branch=master)](https://travis-ci.org/CrossLead/crosslytics.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/CrossLead/crosslytics/badge.svg?branch=master)](https://coveralls.io/github/CrossLead/crosslytics?branch=master)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

Expand Down
20 changes: 17 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"type": "git",
"url": "https://github.com/CrossLead/crosslytics.git"
},
"author": "",
"author": {
"name": "Christian Yang",
"email": "christian.yang@crosslead.com",
"url": "https://crosslead.com/"
},
"keywords": [
""
],
Expand All @@ -18,13 +22,13 @@
"typings": "lib/index.d.ts",
"scripts": {
"clean": "rimraf lib && rimraf coverage && rimraf .nyc_output && rimraf lib_test",
"prettier": "prettier --write \"{src,test}/**/*.ts\"",
"prettier": "prettier --write \"src/**/*.ts\"",
"lint": "tslint --force --format verbose \"src/**/*.ts\"",
"commitmsg": "validate-commit-msg",
"prepublish": "npm run build",
"prebuild": "npm run clean && npm run prettier && npm run lint && echo Using TypeScript && tsc --version",
"build": "tsc --pretty",
"test": "npm run clean && tsc -p tsconfig.test.json --pretty && nyc --exclude \"**/*-spec.js\" ava \"**/*-spec.js\" --verbose",
"test": "npm run clean && tsc -p tsconfig.test.json --pretty && nyc ava --verbose",
"coverage": "nyc report --reporter=lcov --reporter=text --reporter=html",
"watch": "npm run build -- --watch",
"watch:test": "npm run test -- --watch",
Expand Down Expand Up @@ -52,6 +56,16 @@
"ava": {
"require": [
"babel-register"
],
"files": [
"./lib_test/**/*.{spec,e2e}.js"
],
"failFast": true,
"concurrency": 4
},
"nyc": {
"exclude": [
"**/*.{spec,e2e}.js"
]
},
"release": {
Expand Down
2 changes: 1 addition & 1 deletion test/greeter-spec.ts → src/greeter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from "ava";
import { Greeter } from "../src/greeter";
import { Greeter } from "./greeter";

test("Should greet with message", t => {
const greeter = new Greeter("friend");
Expand Down
2 changes: 1 addition & 1 deletion test/index-spec.ts → src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from "ava";
import * as index from "../src/index";
import * as index from "./index";

test("Should have Greeter available", t => {
t.truthy(index.Greeter);
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
],
"exclude": [
"node_modules",
"**/*-spec.ts"
"**/*.spec.ts",
"**/*.e2e.ts"
]
}
3 changes: 2 additions & 1 deletion tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"inlineSourceMap": true
},
"include": [
"test/**/*"
"**/*.spec.ts",
"**/*.e2e.ts"
]
}

0 comments on commit c994174

Please sign in to comment.