Skip to content

Commit c842923

Browse files
committed
Alternative approach: Check for REST API error
1 parent 7e5ce85 commit c842923

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

tests/e2e/specs/gutenberg-plugin.test.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,21 @@ test.describe( 'Gutenberg plugin', () => {
1111
// Install Gutenberg plugin if it's not yet installed.
1212
const pluginsMap = await requestUtils.getPluginsMap();
1313
if ( ! pluginsMap.gutenberg ) {
14-
await requestUtils.rest( {
15-
method: 'POST',
16-
path: 'wp/v2/plugins?slug=gutenberg',
17-
} );
14+
try {
15+
await requestUtils.rest( {
16+
method: 'POST',
17+
path: 'wp/v2/plugins?slug=gutenberg',
18+
} );
19+
} catch ( error ) {
20+
if (
21+
typeof error === 'object' &&
22+
error !== null &&
23+
Object.prototype.hasOwnProperty.call( error, 'code' ) &&
24+
error.code === 'incompatible_wp_required_version'
25+
) {
26+
test.skip();
27+
}
28+
}
1829
}
1930

2031
// Refetch installed plugin details. It avoids stale values when the test installs the plugin.

0 commit comments

Comments
 (0)