diff --git a/.gitignore b/.gitignore index e677ecec..be906e95 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,8 @@ .DS_Store # IDE-specific -.phpunit.result.cachecghooks.lock +.phpunit.result.cache +cghooks.lock # Vendor code /node_modules/ diff --git a/README.md b/README.md index b8d7c37c..71497eea 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,15 @@ You will mainly need these two commands: `npm run build` - Transforms your code according to the configuration provided, so it’s ready for production and optimized for the best performance. `npm run start`- Transforms your code according to the configuration provided, so it’s ready for development. The script will automatically rebuild if you make changes to the code, and you will see the build errors in the console. +### Testing and linting + +With `wp-env` running: + +`npm run php-install` - Installs the Composer dependencies inside `wp-env`. +`npm run test:php` - Runs the PHPUnit tests inside `wp-env`. Extra PHPUnit arguments can be passed after `--`, e.g. `npm run test:php -- --filter Test_Model_Message`. + +`npm run lint:js` and `npm run lint:css` lint the JavaScript/TypeScript and SCSS source files. + ## Demo notifications To install a few demo notifications for testing purposes, you can download and install [this plugin](https://gist.github.com/jonathanbossenger/63828e3bc436021ffedced0c67dc5450). diff --git a/package.json b/package.json index de9fec75..6261f340 100644 --- a/package.json +++ b/package.json @@ -31,20 +31,19 @@ "start:storybook": "npm run start --workspace=storybook", "build": "wp-scripts build", "build:storybook": "npm run build --workspace=storybook", - "php-install": "wp-env run composer 'composer --ignore-platform-req=php install'", + "php-install": "wp-env run cli --env-cwd=wp-content/plugins/wp-feature-notifications composer install --ignore-platform-req=php", "packages-update": "wp-scripts packages-update", "check-engines": "wp-scripts check-engines", "check-licenses": "wp-scripts check-licenses", "format": "wp-scripts format", - "lint:css": "wp-scripts lint-style ./src", + "lint:css": "wp-scripts lint-style \"src/**/*.scss\"", "lint:js": "wp-scripts lint-js ./src", "lint:md:docs": "wp-scripts lint-md-docs ./src", "lint:pkg-json": "wp-scripts lint-pkg-json ./src", "plugin-zip": "wp-scripts plugin-zip", "test:js": "echo \"🚧 TEST JS: WE'LL THINK ABOUT IT LATER 🚧\" && exit 0", - "test:php": "wp-env run phpunit 'phpunit --configuration=/var/www/html/wp-content/plugins/wp-feature-notifications/phpunit.xml.dist'", + "test:php": "wp-env run tests-cli --env-cwd=wp-content/plugins/wp-feature-notifications vendor/bin/phpunit", "test": "npm run test:php && npm run test:js", - "docGen": "npx docgen src/scripts/wp-notifications.js", "prepare": "husky" }, "repository": { @@ -84,7 +83,7 @@ "prettier": "@wordpress/prettier-config", "stylelint": { "extends": [ - "@wordpress/stylelint-config" + "@wordpress/stylelint-config/scss" ] } }