Skip to content

Commit 31e886c

Browse files
authored
Set up Prettier (#36)
* Set up prettier * Run prettier
1 parent d66fabd commit 31e886c

File tree

14 files changed

+353
-247
lines changed

14 files changed

+353
-247
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: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Karmatic is a zero-configuration wrapper around these tools with intelligent def
1212

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

15-
1615
## Installation
1716

1817
```sh
@@ -31,7 +30,6 @@ npm i -D webpack karmatic
3130

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

34-
3533
### Test File Patterns
3634

3735
By default, Karmatic will find tests in any files ending in `.test.js` or `_test.js`.
@@ -41,7 +39,6 @@ You can change this to any minimatch pattern _(note the quotes to avoid shell ex
4139
karmatic '**/*Spec.jsx?'
4240
```
4341

44-
4542
## Usage
4643

4744
```text
@@ -69,27 +66,23 @@ To disable any option that defaults to `true`, pass `false` to the option: `--he
6966

7067
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.
7168

72-
7369
## FAQ
7470

75-
**Q**: [Is there an FAQ?](https://twitter.com/gauntface/status/956259291928776704)**
71+
**Q**: [Is there an FAQ?](https://twitter.com/gauntface/status/956259291928776704)\*\*
7672

7773
> Yes.
7874
79-
8075
## Projects Using Karmatic
8176

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

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

86-
8781
## License
8882

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

91-
92-
[Karma]: https://karma-runner.github.io
93-
[Webpack]: https://webpack.js.org
94-
[Jasmine]: https://jasmine.github.io
95-
[Puppeteer]: https://github.com/GoogleChrome/puppeteer
85+
[karma]: https://karma-runner.github.io
86+
[webpack]: https://webpack.js.org
87+
[jasmine]: https://jasmine.github.io
88+
[puppeteer]: https://github.com/GoogleChrome/puppeteer

package.json

Lines changed: 72 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +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-
"expect": "^24.9.0",
49-
"istanbul-instrumenter-loader": "^3.0.1",
50-
"jasmine-core": "^3.3.0",
51-
"karma": "^4.3.0",
52-
"karma-chrome-launcher": "^3.1.0",
53-
"karma-coverage": "^2.0.1",
54-
"karma-firefox-launcher": "^1.2.0",
55-
"karma-jasmine": "^2.0.1",
56-
"karma-sauce-launcher": "^2.0.2",
57-
"karma-sourcemap-loader": "^0.3.7",
58-
"karma-spec-reporter": "0.0.32",
59-
"karma-webpack": "^4.0.2",
60-
"minimatch": "^3.0.4",
61-
"puppeteer": "^1.19.0",
62-
"sade": "^1.6.1",
63-
"script-loader": "^0.7.2"
64-
},
65-
"peerDependencies": {
66-
"webpack": ">=4"
67-
}
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+
}
6874
}

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

@@ -28,15 +33,15 @@ prog
2833
prog
2934
.command('watch [...files]')
3035
.describe('Run tests on any change')
31-
.action( (str, opts) => run(str, opts, true) );
36+
.action((str, opts) => run(str, opts, true));
3237

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

4146
prog.parse(process.argv);
4247

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

0 commit comments

Comments
 (0)