Skip to content

Commit 0b0cf73

Browse files
feat(create-jest): Add npm init / yarn create initialiser (#14453)
Co-authored-by: Tom Mrazauskas <tom@mrazauskas.de>
1 parent 008caa9 commit 0b0cf73

File tree

45 files changed

+187
-55
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+187
-55
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ module.exports = {
357357
files: [
358358
'scripts/*',
359359
'packages/*/__benchmarks__/test.js',
360-
'packages/jest-cli/src/init/index.ts',
360+
'packages/create-jest/src/runCreate.ts',
361361
'packages/jest-repl/src/cli/runtime-cli.ts',
362362
],
363363
rules: {

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Features
44

5+
- `[create-jest]` Add `npm init` / `yarn create` initialiser for Jest projects ([#14465](https://github.com/jestjs/jest/pull/14453))
6+
57
### Fixes
68

79
- `[jest-snapshot]` Allow for strings as well as template literals in inline snapshots ([#14465](https://github.com/jestjs/jest/pull/14465))
@@ -13,6 +15,8 @@
1315

1416
### Chore & Maintenance
1517

18+
- `[jest-cli]` Move internal config initialisation logic to the `create-jest` package ([#14465](https://github.com/jestjs/jest/pull/14453))
19+
1620
## 29.6.4
1721

1822
### Fixes

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ If you'd like to learn more about running `jest` through the command line, take
131131
Based on your project, Jest will ask you a few questions and will create a basic configuration file with a short description for each option:
132132

133133
```bash
134-
jest --init
134+
yarn create jest
135135
```
136136

137137
### Using Babel

docs/GettingStarted.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ If you'd like to learn more about running `jest` through the command line, take
6767

6868
Based on your project, Jest will ask you a few questions and will create a basic configuration file with a short description for each option:
6969

70-
```bash
71-
jest --init
70+
```bash npm2yarn
71+
npm init jest@latest
7272
```
7373

7474
### Using Babel

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"test": "yarn lint && yarn jest",
112112
"typecheck": "yarn typecheck:examples && yarn typecheck:tests",
113113
"typecheck:examples": "tsc -p examples/angular --noEmit && tsc -p examples/expect-extend --noEmit && tsc -p examples/typescript --noEmit",
114-
"typecheck:tests": "tsc -b packages/{babel-jest,babel-plugin-jest-hoist,diff-sequences,expect,expect-utils,jest-circus,jest-cli,jest-config,jest-console,jest-snapshot,jest-util,jest-validate,jest-watcher,jest-worker,pretty-format}/**/__tests__",
114+
"typecheck:tests": "tsc -b packages/{babel-jest,babel-plugin-jest-hoist,create-jest,diff-sequences,expect,expect-utils,jest-circus,jest-cli,jest-config,jest-console,jest-snapshot,jest-util,jest-validate,jest-watcher,jest-worker,pretty-format}/**/__tests__",
115115
"verify-old-ts": "node ./scripts/verifyOldTs.mjs",
116116
"verify-pnp": "node ./scripts/verifyPnP.mjs",
117117
"watch": "yarn build:js && node ./scripts/watch.mjs",

packages/create-jest/.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**/__mocks__/**
2+
**/__tests__/**
3+
__typetests__
4+
src
5+
tsconfig.json
6+
tsconfig.tsbuildinfo
7+
api-extractor.json
8+
.eslintcache

packages/create-jest/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# create-jest
2+
3+
> Getting started with Jest with a single command
4+
5+
```bash
6+
npm init jest@latest
7+
# Or for Yarn
8+
yarn create jest
9+
# Or for pnpm
10+
pnpm create jest
11+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Copyright (c) Meta Platforms, Inc. and affiliates.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
require('..').runCLI();

packages/create-jest/package.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "create-jest",
3+
"description": "Create a new Jest project",
4+
"version": "29.6.4",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/jestjs/jest.git",
8+
"directory": "packages/create-jest"
9+
},
10+
"license": "MIT",
11+
"bin": "./bin/create-jest.js",
12+
"main": "./build/index.js",
13+
"types": "./build/index.d.ts",
14+
"exports": {
15+
".": {
16+
"types": "./build/index.d.ts",
17+
"default": "./build/index.js"
18+
},
19+
"./package.json": "./package.json",
20+
"./bin/create-jest": "./bin/create-jest.js"
21+
},
22+
"dependencies": {
23+
"@jest/types": "workspace:^",
24+
"chalk": "^4.0.0",
25+
"exit": "^0.1.2",
26+
"graceful-fs": "^4.2.9",
27+
"jest-config": "workspace:^",
28+
"jest-util": "workspace:^",
29+
"prompts": "^2.0.1"
30+
},
31+
"engines": {
32+
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
33+
},
34+
"publishConfig": {
35+
"access": "public"
36+
},
37+
"devDependencies": {
38+
"@types/exit": "^0.1.30",
39+
"@types/graceful-fs": "^4.1.3",
40+
"@types/prompts": "^2.0.1"
41+
}
42+
}

0 commit comments

Comments
 (0)