Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.wp-env.json schema: Fix schema and add unit tests #63281

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Simplify
  • Loading branch information
t-hamano committed Jul 25, 2024
commit fe3986c3365c28018fe75e7dd778ea296d524e18
11 changes: 3 additions & 8 deletions test/integration/wp-env-schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
* External dependencies
*/
import Ajv from 'ajv';
import glob from 'fast-glob';

/**
* Internal dependencies
*/
import wpEnvSchema from '../../schemas/json/wp-env.json';
import wpEnvJsonFile from '../../.wp-env.json';

describe( '.wp-env.json schema', () => {
const jsonFiles = glob.sync( [ '.wp-env.json' ], { onlyFiles: true } );
const ajv = new Ajv( {
allowMatchingProperties: true,
} );
Expand All @@ -25,13 +24,9 @@ describe( '.wp-env.json schema', () => {
expect( result.errors ).toBe( null );
} );

test( 'found .wp-env.json files', () => {
expect( jsonFiles.length ).toBeGreaterThan( 0 );
} );

test.each( jsonFiles )( 'validates schema for `%s`', ( filepath ) => {
test( 'validates schema for .wp-env.json', () => {
// We want to validate the .wp-env.json file using the local schema.
const { $schema, ...metadata } = require( filepath );
const { $schema, ...metadata } = wpEnvJsonFile;

// we expect the $schema property to be present in the .wp-env.json file
expect( $schema ).toBeTruthy();
Expand Down
Loading