An open API service indexing awesome lists of open source software.

https://github.com/xwp/wp-qunit-print-script-dependencies

QUnit Print Script Dependencies WP-CLI Command
https://github.com/xwp/wp-qunit-print-script-dependencies

Last synced: 3 months ago
JSON representation

QUnit Print Script Dependencies WP-CLI Command

Awesome Lists containing this project

README

          

# QUnit Print Script Dependencies WP-CLI Command

Print dependencies for scripts to be tested and then add into a QUnit HTML test runner file ([see where in the main WP Core QUnit test suite](https://github.com/xwp/wordpress-develop/blob/63755028e8340445ed6062eeba4fa82e3087e433/tests/qunit/index.html#L6-L13), for example).
Uses `wp_print_scripts()` and will include any attached script data or before/after inline scripts. This eliminates a lot of tedious effort
to code up these script tags by hand.

## Examples

Print dependencies for `wp-a11y`:

```
$ wp qunit-print-script-dependencies wp-a11y

```

Print dependencies for `wp-util`:

```
$ wp qunit-print-script-dependencies wp-util

/* <![CDATA[ */
var _wpUtilSettings = {"ajax":{"url":"\/wp-admin\/admin-ajax.php"}};
/* ]]> */

```

Print dependencies for `wp-util` and `media-models` with overridden base URL.
In this case, it is expected that the script tags would be added to a plugin QUnit test runner
located somewhere like `wp-content/plugins/foo/tests/qunit`:

```
$ wp qunit-print-script-dependencies media-models wplink --base_href=../../../../../

/* <![CDATA[ */
var _wpUtilSettings = {"ajax":{"url":"\/wp-admin\/admin-ajax.php"}};
/* ]]> */

/* <![CDATA[ */
var _wpMediaModelsL10n = {"settings":{"ajaxurl":"\/wp-admin\/admin-ajax.php","post":{"id":0}}};
/* ]]> */

/* <![CDATA[ */
var wpLinkL10n = {"title":"Insert\/edit link","update":"Update","save":"Add Link","noTitle":"(no title)","noMatchesFound":"No results found.","linkSelected":"Link selected.","linkInserted":"Link inserted."};
/* ]]> */

```

## Credits

By [XWP](https://make.xwp.co). Licensed GPLv2.