How to use the @wordpress/e2e-tests/fixtures.writeBlockFixtureJSON function in @wordpress/e2e-tests

To help you get started, we’ve selected a few @wordpress/e2e-tests examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WordPress / gutenberg / test / integration / full-content / full-content.spec.js View on Github external
const {
				filename: jsonFixtureFileName,
				file: jsonFixtureContent,
			} = getBlockFixtureJSON( basename );

			let blocksExpectedString;

			if ( jsonFixtureContent ) {
				blocksExpectedString = jsonFixtureContent;
			} else if ( process.env.GENERATE_MISSING_FIXTURES ) {
				blocksExpectedString = JSON.stringify(
					blocksActualNormalized,
					null,
					4
				) + '\n';
				writeBlockFixtureJSON( basename, blocksExpectedString );
			} else {
				throw new Error(
					`Missing fixture file: ${ jsonFixtureFileName }`
				);
			}

			const blocksExpected = JSON.parse( blocksExpectedString );
			try {
				expect(
					blocksActualNormalized
				).toEqual( blocksExpected );
			} catch ( err ) {
				throw new Error( format(
					"File '%s' does not match expected value:\n\n%s",
					jsonFixtureFileName,
					err.message