Skip to content

Commit da02ba5

Browse files
authored
Merge branch 'master' into add_datadir
2 parents e9867df + 31e886c commit da02ba5

File tree

15 files changed

+373
-245
lines changed

15 files changed

+373
-245
lines changed

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
coverage
2+
dist
3+
node_modules
4+
package-lock.json

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"arrowParens": "always",
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"endOfLine": "lf",
6+
"useTabs": true
7+
}

README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
A simplified zero-configuration wrapper around [Karma], [Webpack], [Jasmine] & [Puppeteer].
44

5+
Think of it like Jest for cross-browser testing (it uses the same [expect syntax](https://jestjs.io/docs/en/using-matchers)).
56

67
## Why do I want this?
78

@@ -11,7 +12,6 @@ Karmatic is a zero-configuration wrapper around these tools with intelligent def
1112

1213
Most importantly, Karmatic provides a (headless) browser test harness in a single dependency.
1314

14-
1515
## Installation
1616

1717
```sh
@@ -30,7 +30,6 @@ npm i -D webpack karmatic
3030

3131
... now you can run your tests using `npm t`. Here's a [minimal example repo](https://gist.github.com/developit/acd8a075350eeb6574439e92888c50cf).
3232

33-
3433
### Test File Patterns
3534

3635
By default, Karmatic will find tests in any files ending in `.test.js` or `_test.js`.
@@ -78,27 +77,23 @@ To disable any option that defaults to `true`, pass `false` to the option: `--he
7877

7978
NOTE: The `debug` option overrides the default value of the `--headless` and `--coverage` option to be `false`. This option will also open up the local Puppeteer installation of Chrome, not your globally installed one. If you'd like to debug your tests using your your own instance of Chrome (or any other browser), copy the URL from the puppeteer window into your favorite browser.
8079

81-
8280
## FAQ
8381

84-
**Q**: [Is there an FAQ?](https://twitter.com/gauntface/status/956259291928776704)**
82+
**Q**: [Is there an FAQ?](https://twitter.com/gauntface/status/956259291928776704)\*\*
8583

8684
> Yes.
8785
88-
8986
## Projects Using Karmatic
9087

9188
Karmatic is pretty new! Here are some projects that have switched to it you may use as a reference:
9289

9390
- [workerize-loader](https://github.com/developit/workerize-loader/commit/afaa20bbfbdec1d6a5523ec69ba2a2d5d495cfd6)
9491

95-
9692
## License
9793

9894
[MIT](https://oss.ninja/mit/developit) © [developit](https://github.com/developit)
9995

100-
101-
[Karma]: https://karma-runner.github.io
102-
[Webpack]: https://webpack.js.org
103-
[Jasmine]: https://jasmine.github.io
104-
[Puppeteer]: https://github.com/GoogleChrome/puppeteer
96+
[karma]: https://karma-runner.github.io
97+
[webpack]: https://webpack.js.org
98+
[jasmine]: https://jasmine.github.io
99+
[puppeteer]: https://github.com/GoogleChrome/puppeteer

package.json

Lines changed: 72 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,74 @@
11
{
2-
"name": "karmatic",
3-
"version": "1.4.0",
4-
"description": "Zero-config automatic (headless) browser testing. Powered by Karma, Webpack & Jasmine.",
5-
"main": "dist/index.js",
6-
"module": "dist/index.m.js",
7-
"bin": "dist/cli.js",
8-
"scripts": {
9-
"prepare": "npm t",
10-
"build": "microbundle --target node -f cjs --no-compress src/*.js",
11-
"test:build": "node ./dist/cli.js run",
12-
"test:watch": "node ./dist/cli.js watch --headless false",
13-
"test": "eslint src test && npm run -s build && npm run -s test:build",
14-
"release": "npm run -s prepare && npm test && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
15-
},
16-
"eslintConfig": {
17-
"extends": "eslint-config-developit"
18-
},
19-
"keywords": [
20-
"karma",
21-
"chrome",
22-
"test runner"
23-
],
24-
"files": [
25-
"dist"
26-
],
27-
"author": "Jason Miller <[email protected]> (http://jasonformat.com)",
28-
"repository": "developit/karmatic",
29-
"license": "MIT",
30-
"devDependencies": {
31-
"eslint": "^4.16.0",
32-
"eslint-config-developit": "^1.1.1",
33-
"microbundle": "^0.11.0",
34-
"webpack": "^4.39.3",
35-
"workerize-loader": "^1.1.0"
36-
},
37-
"dependencies": {
38-
"@babel/core": "^7.5.5",
39-
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",
40-
"@babel/plugin-transform-react-jsx": "^7.3.0",
41-
"@babel/polyfill": "^7.4.4",
42-
"@babel/preset-env": "^7.5.5",
43-
"@babel/preset-stage-0": "^7.0.0",
44-
"babel-loader": "^8.0.6",
45-
"babel-plugin-istanbul": "^5.2.0",
46-
"chalk": "^2.3.0",
47-
"dlv": "^1.1.3",
48-
"istanbul-instrumenter-loader": "^3.0.1",
49-
"jasmine-core": "^3.3.0",
50-
"karma": "^4.3.0",
51-
"karma-chrome-launcher": "^3.1.0",
52-
"karma-coverage": "^2.0.1",
53-
"karma-firefox-launcher": "^1.2.0",
54-
"karma-jasmine": "^2.0.1",
55-
"karma-sauce-launcher": "^2.0.2",
56-
"karma-sourcemap-loader": "^0.3.7",
57-
"karma-spec-reporter": "0.0.32",
58-
"karma-webpack": "^4.0.2",
59-
"minimatch": "^3.0.4",
60-
"puppeteer": "^1.19.0",
61-
"sade": "^1.6.1",
62-
"script-loader": "^0.7.2"
63-
},
64-
"peerDependencies": {
65-
"webpack": ">=4"
66-
}
2+
"name": "karmatic",
3+
"version": "1.4.0",
4+
"description": "Zero-config automatic (headless) browser testing. Powered by Karma, Webpack & Jasmine.",
5+
"main": "dist/index.js",
6+
"module": "dist/index.m.js",
7+
"bin": "dist/cli.js",
8+
"scripts": {
9+
"prepare": "npm t",
10+
"build": "microbundle --target node -f cjs --no-compress src/*.js",
11+
"test:build": "node ./dist/cli.js run",
12+
"test:watch": "node ./dist/cli.js watch --headless false",
13+
"prettier": "prettier --write './**/*.{js,json,yml,md}'",
14+
"test": "prettier --check './**/*.{js,json,yml,md}' && eslint src test && npm run -s build && npm run -s test:build",
15+
"release": "npm run -s prepare && npm test && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
16+
},
17+
"eslintConfig": {
18+
"extends": [
19+
"eslint-config-developit",
20+
"prettier"
21+
]
22+
},
23+
"keywords": [
24+
"karma",
25+
"chrome",
26+
"test runner"
27+
],
28+
"files": [
29+
"dist"
30+
],
31+
"author": "Jason Miller <[email protected]> (http://jasonformat.com)",
32+
"repository": "developit/karmatic",
33+
"license": "MIT",
34+
"devDependencies": {
35+
"eslint": "^4.16.0",
36+
"eslint-config-developit": "^1.1.1",
37+
"eslint-config-prettier": "^6.10.0",
38+
"microbundle": "^0.11.0",
39+
"prettier": "^1.19.1",
40+
"webpack": "^4.39.3",
41+
"workerize-loader": "^1.1.0"
42+
},
43+
"dependencies": {
44+
"@babel/core": "^7.5.5",
45+
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",
46+
"@babel/plugin-transform-react-jsx": "^7.3.0",
47+
"@babel/polyfill": "^7.4.4",
48+
"@babel/preset-env": "^7.5.5",
49+
"@babel/preset-stage-0": "^7.0.0",
50+
"babel-loader": "^8.0.6",
51+
"babel-plugin-istanbul": "^5.2.0",
52+
"chalk": "^2.3.0",
53+
"dlv": "^1.1.3",
54+
"expect": "^24.9.0",
55+
"istanbul-instrumenter-loader": "^3.0.1",
56+
"jasmine-core": "^3.3.0",
57+
"karma": "^4.3.0",
58+
"karma-chrome-launcher": "^3.1.0",
59+
"karma-coverage": "^2.0.1",
60+
"karma-firefox-launcher": "^1.2.0",
61+
"karma-jasmine": "^2.0.1",
62+
"karma-sauce-launcher": "^2.0.2",
63+
"karma-sourcemap-loader": "^0.3.7",
64+
"karma-spec-reporter": "0.0.32",
65+
"karma-webpack": "^4.0.2",
66+
"minimatch": "^3.0.4",
67+
"puppeteer": "^1.19.0",
68+
"sade": "^1.6.1",
69+
"script-loader": "^0.7.2"
70+
},
71+
"peerDependencies": {
72+
"webpack": ">=4"
73+
}
6774
}

src/appender.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { cleanStack } from './lib/util';
33

44
export function configure(config, layouts) {
55
let layout = layouts.colouredLayout;
6-
return logEvent => {
7-
process.stdout.write(chalk.red(cleanStack(layout(logEvent, config.timezoneOffset)))+'\n');
6+
return (logEvent) => {
7+
process.stdout.write(
8+
chalk.red(cleanStack(layout(logEvent, config.timezoneOffset))) + '\n'
9+
);
810
};
9-
}
11+
}

src/cli.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import { cleanStack } from './lib/util';
99
// @ts-ignore
1010
const { version } = require('../package.json');
1111

12-
let toArray = val => typeof val === 'string' ? val.split(/\s*,\s*/) : val == null ? [] : [].concat(val);
12+
let toArray = (val) =>
13+
typeof val === 'string'
14+
? val.split(/\s*,\s*/)
15+
: val == null
16+
? []
17+
: [].concat(val);
1318

1419
let prog = sade('karmatic');
1520

@@ -29,15 +34,15 @@ prog
2934
prog
3035
.command('watch [...files]')
3136
.describe('Run tests on any change')
32-
.action( (str, opts) => run(str, opts, true) );
37+
.action((str, opts) => run(str, opts, true));
3338

3439
prog
3540
.command('debug [...files]')
3641
.describe('Open a headful Puppeteer instance for debugging your tests')
3742
.option('--headless', 'Run using Chrome Headless', false) // Override default to false
3843
.option('--browsers', 'Run in specific browsers', null)
3944
.option('--coverage', 'Report code coverage of tests', false) // Override default to false
40-
.action( (str, opts) => run(str, opts, true) );
45+
.action((str, opts) => run(str, opts, true));
4146

4247
prog.parse(process.argv);
4348

@@ -47,13 +52,16 @@ function run(str, opts, isWatch) {
4752
const b = opts.browsers || opts.browser;
4853
opts.browsers = b ? toArray(b) : null;
4954
karmatic(opts)
50-
.then( output => {
51-
if (output!=null) process.stdout.write(output + '\n');
55+
.then((output) => {
56+
if (output != null) process.stdout.write(output + '\n');
5257
if (!opts.watch) process.exit(0);
5358
})
54-
.catch(err => {
55-
if (!(typeof err.code==='number' && err.code>=0 && err.code<10)) {
56-
process.stderr.write(chalk.red(cleanStack(err && (err.stack || err.message) || err)) + '\n');
59+
.catch((err) => {
60+
if (!(typeof err.code === 'number' && err.code >= 0 && err.code < 10)) {
61+
process.stderr.write(
62+
chalk.red(cleanStack((err && (err.stack || err.message)) || err)) +
63+
'\n'
64+
);
5765
}
5866
process.exit(err.code || 1);
5967
});

0 commit comments

Comments
 (0)