Skip to content

Commit 21be32d

Browse files
committed
refactor(tdd-buffet): Move jest config to separate package
BREAKING CHANGE: `require('tdd-buffet/config/jest.config.js')` is now replaced by `require('@tdd-buffet/jest-config')`
1 parent 002953e commit 21be32d

18 files changed

+709
-90
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This is an opinionated collection of libraries and tools for writing tests and e
1616
- Appetizers
1717
- [Configs](./packages/tdd-buffet/README.md#configs)
1818
- [TypeScript](./packages/tdd-buffet/README.md#typescript)
19-
- [Jest](./packages/tdd-buffet/README.md#jest)
19+
- [Jest](./packages/jest-config/README.md)
2020
- Main courses
2121
- [Testing](./packages/tdd-buffet/README.md#testing)
2222
- [Create a Node test](./packages/tdd-buffet/README.md#create-a-node-test)

packages/jest-config/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 Andrei Picus
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/jest-config/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
> Awesome jest config for TypeScript apps
2+
3+
[![Build Status](https://travis-ci.com/NiGhTTraX/tdd-buffet.svg?branch=master)](https://travis-ci.com/NiGhTTraX/tdd-buffet) [![codecov](https://codecov.io/gh/NiGhTTraX/tdd-buffet/branch/master/graph/badge.svg)](https://codecov.io/gh/NiGhTTraX/tdd-buffet) ![npm type definitions](https://img.shields.io/npm/types/@tdd-buffet/jest-config.svg)
4+
5+
----
6+
7+
## Install
8+
9+
```sh
10+
npm install @tdd-buffet/jest-config
11+
```
12+
13+
## Usage
14+
15+
The config is focused on providing a good developer experience with TypeScript. Tests are type checked before they are run and certain harmful options in `tsconfing.json` files are turned off. You can always inspect the config and override it.
16+
17+
```js
18+
const baseConfig = require('@tdd-buffet/jest-config');
19+
20+
module.exports = {
21+
...baseConfig
22+
};
23+
```

packages/jest-config/package.json

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "@tdd-buffet/jest-config",
3+
"publishConfig": {
4+
"access": "public",
5+
"directory": "dist"
6+
},
7+
"version": "0.0.1",
8+
"description": "Awesome jest config",
9+
"keywords": [
10+
"tdd",
11+
"jest",
12+
"testing"
13+
],
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/NiGhTTraX/tdd-buffet.git",
17+
"directory": "packages/jest-config"
18+
},
19+
"author": "Andrei Picus",
20+
"license": "MIT",
21+
"homepage": "https://github.com/NiGhTTraX/tdd-buffet/tree/master/packages/jest-config",
22+
"main": "src/index.js",
23+
"scripts": {
24+
"test": "jest --config src/index.js"
25+
},
26+
"peerDependencies": {
27+
"jest": "^25.2.2"
28+
},
29+
"dependencies": {
30+
"@jest/transform": "~25.2.0",
31+
"@jest/types": "~25.2.0",
32+
"@types/fs-extra": "~8.1.0",
33+
"@types/istanbul-lib-coverage": "~2.0.1",
34+
"fs-extra": "~9.0.0",
35+
"istanbul-lib-coverage": "~3.0.0",
36+
"jest-runtime": "~25.2.0",
37+
"ts-jest": "~25.2.0",
38+
"typescript": "~3.8.0",
39+
"whatwg-fetch": "~3.0.0"
40+
},
41+
"devDependencies": {
42+
"@types/jest": "~25.1.4",
43+
"@types/node": "~12.12.0",
44+
"jest": "~25.2.2"
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { expect } from 'tdd-buffet/expect/chai';
2-
import { describe, it } from 'tdd-buffet/suite/node';
31
import './png.png';
42
import './styles.css';
53

@@ -9,6 +7,6 @@ describe('Jest config', () => {
97
});
108

119
it('should polyfill fetch', () => {
12-
expect(fetch).to.be.a('function');
10+
expect(fetch).toBeInstanceOf(Function);
1311
});
1412
});
File renamed without changes.
File renamed without changes.

packages/tdd-buffet/README.md

+1-13
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('Expect', () => {
7878
npx tdd-buffet test
7979
```
8080

81-
This will run all the tests matched by the default [Jest config](#jest). You can pass your own config through the `--config` option. The command accepts all Jest arguments:
81+
This will run all the tests matched by the default [Jest config](../jest-config). You can pass your own config through the `--config` option. The command accepts all Jest arguments:
8282

8383
```shell script
8484
npx tdd-buffet test --runInBand tests/my-test.spec.tsx
@@ -110,15 +110,3 @@ The config provides sane defaults for both library and app developers. No `jsx`
110110
}
111111
}
112112
```
113-
114-
### Jest
115-
116-
The config is focused on providing a good developer experience with TypeScript. Tests are type checked before they are run and certain harmful options in `tsconfing.json` files are turned off. You can always inspect the config and override it.
117-
118-
```js
119-
const baseConfig = require('tdd-buffet/config/jest.config.js');
120-
121-
module.exports = {
122-
...baseConfig
123-
};
124-
```

packages/tdd-buffet/package.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,18 @@
3030
"prepublishOnly": "yarn run build && yarn run package"
3131
},
3232
"dependencies": {
33-
"@jest/transform": "~25.2.0",
3433
"@jest/types": "~25.2.0",
3534
"@types/chai": "~4.2.0",
3635
"@types/fs-extra": "~8.1.0",
37-
"@types/istanbul-lib-coverage": "~2.0.1",
38-
"@types/jest": "~25.1.0",
3936
"chai": "~4.2.0",
4037
"execa": "~4.0.0",
4138
"fs-extra": "~9.0.0",
4239
"istanbul-lib-coverage": "~3.0.0",
4340
"jest": "~25.2.0",
44-
"jest-runtime": "~25.2.0",
4541
"meow": "~6.1.0",
46-
"ts-jest": "~25.2.0",
4742
"ts-loader": "~6.2.0",
4843
"typescript": "~3.8.0",
49-
"webdriverio": "~5.22.0",
50-
"whatwg-fetch": "~3.0.0"
44+
"webdriverio": "~5.22.0"
5145
},
5246
"devDependencies": {
5347
"@types/meow": "~5.0.0",

packages/tdd-buffet/src/jest.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
FileCoverageData,
88
} from 'istanbul-lib-coverage';
99
import { run as runJest } from 'jest';
10-
import path from 'path';
1110

1211
/* eslint-disable no-underscore-dangle */
1312
declare global {
@@ -168,7 +167,7 @@ function registerSourceMap(filename: string): boolean {
168167
export async function run(argv: string[]) {
169168
// Push our config if there isn't one specified.
170169
if (!argv.includes('--config')) {
171-
argv.push('--config', path.join(__dirname, './config/jest.config.js'));
170+
argv.push('--config', require.resolve('@tdd-buffet/jest-config'));
172171
}
173172

174173
return runJest(argv);

tests/jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const baseConfig = require('../packages/tdd-buffet/src/config/jest.config');
1+
const baseConfig = require('@tdd-buffet/jest-config');
22

33
module.exports = {
44
...baseConfig,

0 commit comments

Comments
 (0)