Skip to content

Commit c86ba0c

Browse files
committed
🤖 Update LLMs files [skip ci]
1 parent 3660e1c commit c86ba0c

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

‎docusaurus/static/llms-full.txt‎

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12293,6 +12293,10 @@ What the test harness does:
1229312293
6. **User Permission Helper**: Patches the user service to automatically assign the "authenticated" role to newly created users, simplifying authentication tests
1229412294
7. **Cleanup**: Properly closes connections and removes temporary database files after tests complete
1229512295

12296+
:::note
12297+
The code example for the `tests/strapi.js` harness highlights lines 313-321 because these are optional, to be used if you [seed predictable test data](#optional-seed-predictable-test-data).
12298+
:::
12299+
1229612300
Once these files are in place, the harness handles several Strapi 5 requirements automatically, letting you focus on writing actual test logic rather than configuration boilerplate.
1229712301

1229812302
## (optional) Seed predictable test data
@@ -12303,25 +12307,41 @@ Some API tests benefit from having a known set of documents preloaded. You can e
1230312307

1230412308
```js title="./scripts/seed.js"
1230512309
async function seedExampleApp() {
12306-
// Create content, upload files, set permissions, etc.
12310+
// In test environment, skip complex seeding and just log
12311+
if (process.env.NODE_ENV === 'test') {
12312+
console.log('Test seeding: Skipping complex data import (not needed for basic tests)');
12313+
return;
12314+
}
12315+
12316+
const shouldImportSeedData = await isFirstRun();
12317+
if (shouldImportSeedData) {
12318+
try {
12319+
console.log('Setting up the template...');
12320+
await importSeedData();
12321+
console.log('Ready to go');
12322+
} catch (error) {
12323+
console.log('Could not import seed data');
12324+
console.error(error);
12325+
}
12326+
}
1230712327
}
1230812328

12329+
// Allow usage both as a CLI and as a library from tests
1230912330
if (require.main === module) {
12310-
// still works as a CLI: `node ./scripts/seed.js`
12311-
seedExampleApp().catch((err) => {
12312-
console.error(err);
12331+
main().catch((error) => {
12332+
console.error(error);
1231312333
process.exit(1);
1231412334
});
1231512335
}
1231612336

1231712337
module.exports = { seedExampleApp };
1231812338
```
1231912339

12320-
2. In the test harness, call the function when `TEST_SEED=true`.
12340+
2. In the test harness, call the function when `TEST_SEED=true` (see lines 313-321 highlighted in the code example from the [main test harness](#main-test-harness)).
1232112341

1232212342
3. Run your tests with seeding enabled:
1232312343

12324-
</Tabs>
12344+
</Tabs>
1232512345

1232612346
Seeding runs after Strapi starts, so services, permissions, and uploads are available.
1232712347

0 commit comments

Comments
 (0)