Skip to content

Commit bb1312d

Browse files
DavertMikclaude
andcommitted
docs: fix faker import + clarify codeceptjs internal-api intro
- data.md: faker is a named export; restore `import { faker }` and update the install hint from the legacy `faker` package to `@faker-js/faker`. - internal-api.md: lead with the named-import form and demote the `codeceptjs` global to a footnote (it only exists when `noGlobals: false`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 94f4ab6 commit bb1312d

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

docs/data.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,13 @@ Just define how many items of any kind you need and the data factory helper will
258258

259259
To make this work some preparations are required.
260260

261-
At first, you need data generation libraries which are [Rosie](https://github.com/rosiejs/rosie) and [Faker](https://www.npmjs.com/package/faker). Faker can generate random names, emails, texts, and Rosie uses them
261+
At first, you need data generation libraries which are [Rosie](https://github.com/rosiejs/rosie) and [Faker](https://fakerjs.dev). Faker can generate random names, emails, texts, and Rosie uses them
262262
to generate objects using factories.
263263

264264
Install rosie and faker to create a first factory:
265265

266-
```js
267-
npm i rosie faker --save-dev
266+
```sh
267+
npm i rosie @faker-js/faker --save-dev
268268
```
269269

270270
Then create a module which will export a factory for an entity.
@@ -290,7 +290,7 @@ See the example providing a factory for User generation:
290290
```js
291291
// factories/post.js
292292
import { Factory } from 'rosie'
293-
import faker from '@faker-js/faker'
293+
import { faker } from '@faker-js/faker'
294294

295295
export default new Factory().attr('name', () => faker.person.findName()).attr('email', () => faker.internet.email())
296296
```
@@ -342,7 +342,7 @@ See the example providing a factory for User generation:
342342
```js
343343
// factories/post.js
344344
import { Factory } from 'rosie'
345-
import faker from '@faker-js/faker'
345+
import { faker } from '@faker-js/faker'
346346

347347
export default new Factory((buildObj) => {
348348
return {

docs/internal-api.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ title: Internal API
88
In this guide we will overview the internal API of CodeceptJS.
99
This knowledge is required for customization, writing plugins, etc.
1010

11-
CodeceptJS provides an API which can be loaded via `import codeceptjs, { recorder, event, output } from 'codeceptjs'` when CodeceptJS is installed locally. Otherwise, you can load codeceptjs API via global `codeceptjs` object:
11+
CodeceptJS exposes its internal API as named exports of the `codeceptjs` package. Import only what you need:
1212

1313
```js
14-
// via module
15-
import { recorder, event, output } from 'codeceptjs';
16-
// or using global object
17-
const { recorder, event, output } = codeceptjs;
14+
import { recorder, event, output, container, config } from 'codeceptjs'
1815
```
1916

17+
> Older code may have relied on a global `codeceptjs` object (`const { recorder } = codeceptjs`). That global only exists under `noGlobals: false` (the deprecated 3.x default) — prefer named imports.
18+
2019
These internal objects are available:
2120

2221
* [`codecept`](https://github.com/Codeception/CodeceptJS/blob/master/lib/codecept.js): test runner class

0 commit comments

Comments
 (0)