diff --git a/bin/blt b/bin/blt index 1c87f57ea..0218afc6d 100755 --- a/bin/blt +++ b/bin/blt @@ -13,6 +13,7 @@ $robo_namespaces = [ 'ci', 'custom', 'drupal', + 'frontend', 'setup', 'tests', 'vm', diff --git a/phing/build.xml b/phing/build.xml index 479d7561a..7bdfd1bbb 100644 --- a/phing/build.xml +++ b/phing/build.xml @@ -48,9 +48,6 @@ - - - diff --git a/phing/tasks/deploy.xml b/phing/tasks/deploy.xml index 57731ed0d..adc13d4d1 100644 --- a/phing/tasks/deploy.xml +++ b/phing/tasks/deploy.xml @@ -158,7 +158,7 @@ - + diff --git a/phing/tasks/frontend.xml b/phing/tasks/frontend.xml deleted file mode 100644 index cdb221294..000000000 --- a/phing/tasks/frontend.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - diff --git a/readme/testing.md b/readme/testing.md index ca885c550..04a9bbfe9 100644 --- a/readme/testing.md +++ b/readme/testing.md @@ -169,3 +169,12 @@ Project level, functional PHPUnit tests are included in `tests/phpunit`. Any PHP * [Test Driven Development: By Example (book)](http://www.amazon.com/dp/0321146530) * [xUnit Test Patterns: Refactoring Test Code (book for the really serious)](http://amazon.com/dp/0131495054) * [Unit testing: Why bother?](http://soundsoftware.ac.uk/unit-testing-why-bother/) + + +## Frontend Testing + +BLT supports a `frontend-test` target that can be used to execute a variety of testing frameworks. Examples may include Jest, Jasmine, Mocha, Chai, etc. + +### Configuration + +You can [customize the configuration values](extending-blt.md#modifying-blt-configuration) for the `frontend-test` key to enable this capability of BLT. \ No newline at end of file diff --git a/src/Robo/Commands/Frontend/FrontendCommand.php b/src/Robo/Commands/Frontend/FrontendCommand.php new file mode 100644 index 000000000..c8d7c136f --- /dev/null +++ b/src/Robo/Commands/Frontend/FrontendCommand.php @@ -0,0 +1,56 @@ +say("Running frontend tasks..."); + $status_code = $this->invokeCommands([ + 'frontend:build', + 'frontend:setup', + 'frontend:test', + ]); + return $status_code; + } + + /** + * Uses project.yml hooks to run custom defined commands to + * build front end dependencies for custom themes. + * + * @command frontend:build + */ + public function build() { + $this->invokeHook('frontend-build'); + } + + /** + * Uses project.yml hooks to run custom defined commands to + * setup front end dependencies for frontend:build. + * + * @command frontend:setup + */ + public function setup() { + $this->invokeHook('frontend-setup'); + } + + /** + * Uses project.yml hooks to run tests for the frontend as + * + * @command frontend:test + */ + public function test() { + $this->invokeHook('frontend-test'); + } + +} diff --git a/template/blt/project.yml b/template/blt/project.yml index 9fb50acfb..acc31a030 100644 --- a/template/blt/project.yml +++ b/template/blt/project.yml @@ -46,6 +46,11 @@ target-hooks: dir: ${docroot} # E.g., `npm run build`. command: echo 'No frontend-build configured.' + frontend-test: + # E.g., ${docroot}/sites/all/themes/custom/mytheme. + dir: ${docroot} + # E.g., `npm test`. + command: echo 'No frontend-tests configured.' # Executed before configuration is imported. pre-config-import: dir: ${docroot}