Operations

Testing

Run the Node.js test suite and organize feature and unit tests.

Beta · v0.2.0Lanjit APIs may change before the stable release. Review the release notes and upgrade guide before updating.

Lanjit uses the built-in Node.js test runner. Store HTTP flow tests in tests/Feature and isolated class tests in tests/Unit. Keep fixtures independent, test failure paths as well as success paths, and run focused files directly with node --test.

Examples

npm test
node artisan make:test UserApi
import test from 'node:test';
import assert from 'node:assert/strict';

test('user API returns a collection', async () => {
  const response = await fetch('http://127.0.0.1:3333/api/users');
  assert.equal(response.status, 200);

  const payload = await response.json();
  assert.ok(Array.isArray(payload.users));
});
node --test tests/Unit/Router.test.js
node --test tests/Unit/ConsoleKernel.test.js
Edit this page on GitHub

Type to search all documentation.