Skip to content

Development

Steven Thompson edited this page Jun 8, 2023 · 1 revision

Development

Testing against existing Payload installations

In some cases, manual testing is desirable on existing Payload CMS installations.

For example, the https://github.com/payloadcms/plugin-seo adds fields to a collection/global, making sure to add the localized flag where appropriate.

Tests in this repository are against fixtures - but this won't keep up-to-date with the plugin.

https://github.com/thompsonsj/gatbsy-source-payload-cms takes the approach of including a test installation of Gatsby. This would be a welcome improvement, but in the meantime, a quick fix is to add manual logging when required.

For example, to write formatted object dumps to log files (example for the afterChange hook):

import fs from 'fs';

fs.writeFileSync('./current-crowdin-json.json', JSON.stringify(currentCrowdinJsonData, null, 2) , 'utf-8');
fs.writeFileSync('./collection-fields.json', JSON.stringify(collection.fields, null, 2) , 'utf-8');
fs.writeFileSync('./localized-fields.json', JSON.stringify(localizedFields, null, 2) , 'utf-8');
Clone this wiki locally