@gravityforms/gulp-tasks
Version:
Configurable Gulp tasks for use in Gravity Forms projects.
35 lines (28 loc) • 938 B
JavaScript
/**
* @description Safety-net test: verifies that the ESM config.js correctly
* loads a CJS consumer gravityforms.config.js via the createRequire bridge.
*
* @since 2.1.0
*/
const fixturesDir = new URL( './fixtures', import.meta.url ).pathname;
describe( 'config.js CJS consumer loading', () => {
beforeAll( () => {
process.env.PROJECT_DIR = fixturesDir;
} );
afterAll( () => {
delete process.env.PROJECT_DIR;
} );
it( 'loads the consumer gravityforms.config.js and returns config + projectId', async () => {
/**
* @description Dynamically import the ESM config.js after setting
* PROJECT_DIR so it resolves the fixture consumer config.
*
* @since 2.1.0
*/
const { default: getConfig } = await import( '../../config.js' );
const { config, projectId } = getConfig();
expect( config ).toBeDefined();
expect( config.paths ).toBeDefined();
expect( projectId ).toBe( 'test-fixture' );
} );
} );