Development
Monorepo
The payload-crowdin-sync plugin is developed in the plugin folder.
Both the dev and dev-alternative-config folders contain configured local Payload CMS installations that use this plugin.
Build
In the root of the repository:
nx build plugin- build todist/plugin.nx build plugin --watchto build when files change.
Format
nx prettier pluginnx prettier devnx prettier dev-alternative-config
Lint
nx lint pluginnx lint devnx lint dev-alternative-config
Test
In the root of the repository:
npm run testto execute unit and integration tests via Jest.nx test pluginto run plugin tests only.nx test devto run integration tests against thedevPayload install.nx test dev-alternative-configto run integration tests against thedev-alternative-configPayload install.
Plugin test coverage is not 100%, but seeks to cover as many use cases as possible. This includes:
- Testing various field configurations for a collection.
- Using
nockto intercept calls to the Crowdin API and ensure the right calls are being made. - Unit tests to cover as many cases as possible for the supporting functions, which include a lot of recursion.
Jest
A Jest test suite is included comprising of:
- unit tests (
*.spec.ts) within thesrcfolder adjacent to files/functions that they are testing; and - integration tests (
*.test.ts) in thedev/src/lib/testsfolder. - integration tests (
*.test.ts) in thedev-alternative-config/src/lib/testsfolder.
Integration
Integration tests use Payload's Local API to run tests against a configured Payload installation in both the dev and dev-alternative-config folder. Test configuration is based on the way tests are configured in https://github.com/payloadcms/payload/tree/main/test.
Fixtures
Use nx dev dev or nx dev dev-alternative-config to run either of the local Payload installations. These local instances can be used to generate fixtures for use with integration tests.