Skip to content

Commit 7f7aac3

Browse files
committed
initial commit
0 parents  commit 7f7aac3

14 files changed

+726
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
node_modules
3+
*.d.ts
4+
dist

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: node_js
2+
node_js:
3+
- "8"
4+
5+
env:
6+
global:
7+
- BUILD_TIMEOUT=10000

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# TODO changelog
2+
3+
## 1.0.0
4+
5+
* First release

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Copyright (c) 2018 Rich Harris
2+
3+
Permission is hereby granted by the authors of this software, to any person, to use the software for any purpose, free of charge, including the rights to run, read, copy, change, distribute and sell it, and including usage rights to any patents the authors may hold on it, subject to the following conditions:
4+
5+
This license, or a link to its text, must be included with all copies of the software and any derivative works.
6+
7+
Any modification to the software submitted to the authors may be incorporated into the software under the terms of this license.
8+
9+
The software is provided "as is", without warranty of any kind, including but not limited to the warranties of title, fitness, merchantability and non-infringement. The authors have no obligation to provide support or updates for the software, and may not be held liable for any damages, claims or other liability arising from its use.

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# tape-modern
2+
3+
Minimum viable testing framework:
4+
5+
* TAP compliant
6+
* Works in Node and in browsers
7+
* Everything is assumed to be async — no need to faff around with `t.plan` and `t.end`
8+
9+
It requires Node 7.6+, because it uses `async`/`await`.
10+
11+
12+
## Installation
13+
14+
```bash
15+
npm i -D tape-modern
16+
```
17+
18+
19+
## Usage
20+
21+
```js
22+
const { test } = require('tape-modern');
23+
24+
test('these tests will all pass', t => {
25+
t.ok(true);
26+
t.ok(true, 'this time with an optional message');
27+
t.ok('not true, but truthy enough');
28+
29+
t.equal(1 + 1, 2);
30+
t.equal(Math.max(1, 2, 3), 3);
31+
32+
t.throws(() => {
33+
throw new Error('oh no!');
34+
}, /oh no!/);
35+
36+
t.pass('this too shall pass');
37+
});
38+
39+
test('these tests will not pass', t => {
40+
t.equal(42, '42');
41+
t.equal({}, {});
42+
t.fail('womp womp');
43+
});
44+
```
45+
46+
You can create custom assertions by adding methods to `assert`:
47+
48+
```js
49+
const { test, assert } = require('tape-modern');
50+
51+
assert.isArray = (value, msg = 'should be an array') => {
52+
assert.ok(Array.isArray(value), msg);
53+
};
54+
55+
assert.isNotArray = (value, msg = 'should not be an array') => {
56+
assert.ok(!Array.isArray(value), msg);
57+
};
58+
59+
test('things that are array-like', t => {
60+
const divs = document.getElementsByTagName('div');
61+
62+
t.isNotArray(divs);
63+
t.isArray([...divs]);
64+
});
65+
```
66+
67+
You can check when your tests have finished running with the `done` promise:
68+
69+
```js
70+
const { done } = require('tape-modern');
71+
72+
// make it visible to e.g. Puppeteer, so that
73+
// we can do `await page.evaluate(() => done)`
74+
window.done = done;
75+
```
76+
77+
78+
## License
79+
80+
[LIL](LICENSE)

appveyor.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# http://www.appveyor.com/docs/appveyor-yml
2+
3+
version: "{build}"
4+
5+
clone_depth: 10
6+
7+
init:
8+
- git config --global core.autocrlf false
9+
10+
environment:
11+
matrix:
12+
# node.js
13+
- nodejs_version: 8
14+
15+
install:
16+
- ps: Install-Product node $env:nodejs_version
17+
- npm install
18+
19+
build: off
20+
21+
test_script:
22+
- node --version && npm --version
23+
- npm test
24+
25+
matrix:
26+
fast_finish: false
27+
28+
# cache:
29+
# - C:\Users\appveyor\AppData\Roaming\npm-cache -> package.json # npm cache
30+
# - node_modules -> package.json # local npm modules

mocha.opts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--require ts-node/register
2+
test/test.ts

package.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "tape-modern",
3+
"description": "Minimum viable TAP-compliant testing framework",
4+
"version": "1.0.0",
5+
"repository": "Rich-Harris/tape-modern",
6+
"main": "dist/tape-modern.umd.js",
7+
"module": "dist/tape-modern.esm.js",
8+
"types": "types/index.d.ts",
9+
"files": [
10+
"dist",
11+
"types"
12+
],
13+
"devDependencies": {
14+
"@types/mocha": "^2.2.44",
15+
"@types/node": "^8.0.53",
16+
"glob": "^7.1.2",
17+
"mocha": "^4.0.1",
18+
"rollup": "^0.52.0",
19+
"rollup-plugin-node-resolve": "^3.3.0",
20+
"rollup-plugin-typescript": "^0.8.1",
21+
"rollup-plugin-virtual": "^1.0.1",
22+
"sander": "^0.6.0",
23+
"ts-node": "^3.3.0",
24+
"tslib": "^1.9.0",
25+
"typescript": "^2.6.2"
26+
},
27+
"scripts": {
28+
"build-declarations": "tsc -d && node scripts/move-type-declarations.js",
29+
"build": "npm run build-declarations && rollup -c",
30+
"dev": "rollup -cw",
31+
"test": "mocha --opts mocha.opts",
32+
"prepublishOnly": "npm test && npm run build"
33+
},
34+
"license": "LIL"
35+
}

rollup.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import typescript from 'rollup-plugin-typescript';
2+
import resolve from 'rollup-plugin-node-resolve';
3+
import pkg from './package.json';
4+
5+
export default {
6+
input: 'src/index.ts',
7+
output: [
8+
{ file: pkg.main, format: 'umd' },
9+
{ file: pkg.module, format: 'es' }
10+
],
11+
name: 'tape',
12+
plugins: [
13+
resolve(),
14+
typescript({
15+
typescript: require('typescript')
16+
})
17+
],
18+
sourcemap: true
19+
};

scripts/move-type-declarations.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const sander = require('sander');
2+
const glob = require('glob');
3+
4+
for (const file of glob.sync('src/**/*.js')) {
5+
sander.unlinkSync(file);
6+
}
7+
8+
sander.rimrafSync('types');
9+
for (const file of glob.sync('src/**/*.d.ts')) {
10+
sander.renameSync(file).to(file.replace(/^src/, 'types'));
11+
}

0 commit comments

Comments
 (0)