├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ └── feature_request.yml ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── tests.yml ├── LICENSE ├── README.md ├── backstopBuild ├── Dockerfile └── entrypoint.sh ├── commands ├── backstop │ └── backstop └── host │ └── backstop-results ├── docker-compose.backstop.yaml ├── install.yaml └── tests ├── test.bats └── testdata └── .gitmanaged /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: 🐞 Bug report or Support Request 2 | description: Create a report to help us improve. 3 | labels: [bug] 4 | body: 5 | - type: checkboxes 6 | attributes: 7 | label: Preliminary checklist 8 | description: Please complete the following checks before submitting an issue. 9 | options: 10 | - label: I am using the latest stable version of DDEV 11 | required: true 12 | - label: I am using the latest stable version of this add-on 13 | required: true 14 | - type: textarea 15 | attributes: 16 | label: Expected Behavior 17 | description: What did you expect to happen? 18 | validations: 19 | required: true 20 | - type: textarea 21 | attributes: 22 | label: Actual Behavior 23 | description: What actually happened instead? 24 | validations: 25 | required: true 26 | - type: textarea 27 | attributes: 28 | label: Steps To Reproduce 29 | description: Specific steps to reproduce the behavior. 30 | placeholder: | 31 | 1. In this environment... 32 | 2. With this config... 33 | 3. Run `...` 34 | 4. See error... 35 | validations: 36 | required: false 37 | - type: textarea 38 | attributes: 39 | label: Anything else? 40 | description: | 41 | Links? References? Screenshots? Anything that will give us more context about your issue! 42 | 43 | 💡 Attach images or log files by clicking this area to highlight it and dragging files in. 44 | validations: 45 | required: false 46 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: 🚀 Feature request 2 | description: Suggest an idea for this project. 3 | labels: [enhancement] 4 | body: 5 | - type: checkboxes 6 | attributes: 7 | label: Is there an existing issue for this? 8 | description: Please search existing issues to see if one already exists for your request. 9 | options: 10 | - label: I have searched the existing issues 11 | required: true 12 | - type: textarea 13 | attributes: 14 | label: Is your feature request related to a problem? 15 | description: Clearly and concisely describe the problem. (Ex. I'm always frustrated when...) 16 | validations: 17 | required: true 18 | - type: textarea 19 | attributes: 20 | label: Describe your solution 21 | description: Clearly and concisely describe what you want to happen. 22 | validations: 23 | required: true 24 | - type: textarea 25 | attributes: 26 | label: Describe alternatives 27 | description: Clearly and concisely describe any alternative solutions or features you've considered. 28 | validations: 29 | required: false 30 | - type: textarea 31 | attributes: 32 | label: Additional context 33 | description: Add any other context or screenshots about the feature request. 34 | validations: 35 | required: false 36 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## The Issue 2 | 3 | - Fixes #REPLACE_ME_WITH_RELATED_ISSUE_NUMBER 4 | 5 | 6 | 7 | ## How This PR Solves The Issue 8 | 9 | 10 | 11 | ## Manual Testing Instructions 12 | 13 | 14 | 15 | ```bash 16 | ddev add-on get https://github.com/mmunz/ddev-backstopjs/tarball/refs/pull/REPLACE_ME_WITH_THIS_PR_NUMBER/head 17 | ddev restart 18 | ``` 19 | 20 | ## Automated Testing Overview 21 | 22 | 23 | 24 | ## Release/Deployment Notes 25 | 26 | 27 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: tests 2 | on: 3 | pull_request: 4 | push: 5 | branches: [ main, develop ] 6 | 7 | schedule: 8 | - cron: '25 08 * * *' 9 | 10 | workflow_dispatch: 11 | inputs: 12 | debug_enabled: 13 | description: 'Debug with tmate set "debug_enabled"' 14 | required: false 15 | default: "false" 16 | 17 | # Required permissions for keep-alive, used by ddev/github-action-add-on-test 18 | permissions: 19 | actions: write 20 | 21 | jobs: 22 | tests: 23 | strategy: 24 | matrix: 25 | ddev_version: [stable, HEAD] 26 | fail-fast: false 27 | 28 | runs-on: ubuntu-latest 29 | 30 | steps: 31 | - uses: ddev/github-action-add-on-test@v2 32 | with: 33 | ddev_version: ${{ matrix.ddev_version }} 34 | token: ${{ secrets.GITHUB_TOKEN }} 35 | debug_enabled: ${{ github.event.inputs.debug_enabled }} 36 | addon_repository: ${{ env.GITHUB_REPOSITORY }} 37 | addon_ref: ${{ env.GITHUB_REF }} 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![add-on registry](https://img.shields.io/badge/DDEV-Add--on_Registry-blue)](https://addons.ddev.com) 2 | [![tests](https://github.com/mmunz/ddev-backstopjs/actions/workflows/tests.yml/badge.svg)](https://github.com/mmunz/ddev-backstopjs/actions/workflows/tests.yml) 3 | [![last commit](https://img.shields.io/github/last-commit/mmunz/ddev-backstopjs)](https://github.com/mmunz/ddev-backstopjs/commits) 4 | [![release](https://img.shields.io/github/v/release/mmunz/ddev-backstopjs)](https://github.com/mmunz/ddev-backstopjs/releases/latest) 5 | 6 | ## ddev-backstopjs 7 | 8 | This is a ddev-addon for [backstop.js](https://github.com/garris/BackstopJS), a visual regression testing tool. 9 | Backstop is executed in a docker container based on the official [backstopjs docker image](https://hub.docker.com/r/backstopjs/backstopjs). 10 | 11 | This addon just provides the basics to run backstopjs. No backstopjs config is included. See below how to generate a 12 | config and for links to a more advanced example config. 13 | 14 | ## Getting started 15 | 16 | Install this addon with 17 | 18 | ```shell 19 | ddev add-on get mmunz/ddev-backstopjs 20 | ``` 21 | 22 | After that you need to restart the ddev project: 23 | 24 | ```shell 25 | ddev restart 26 | ``` 27 | 28 | **Note: If you haven't downloaded the backstopjs base image before, then it will be downloaded when ddev is restarted. 29 | The backstopjs/backstopjs is about 2.6GB, so this may take some time.** 30 | 31 | 32 | ## Using backstopjs 33 | 34 | ### Configuration 35 | 36 | By default, the backstop tests are expected in $DDEV_APPDIR/tests/backstop. 37 | 38 | Provide your own backstop.js or backstop.json configs there. 39 | 40 | Hint: have a look at my example [backstopjs-config](https://github.com/mmunz/backstopjs-config) 41 | 42 | Alternatively you can create a simple backstop.json config with: 43 | 44 | ```shell 45 | ddev backstop init 46 | ``` 47 | 48 | ### Run tests 49 | 50 | After the config was created it is time to run the tests: 51 | 52 | Create reference screenshots: 53 | 54 | ```shell 55 | ddev backstop reference 56 | ``` 57 | 58 | Create test images and compare to reference screenshots: 59 | 60 | ```shell 61 | ddev backstop test 62 | ``` 63 | 64 | If your config file is not 'backstop.json' you need to use the --config argument, e.g. --config=backstop.js 65 | 66 | ### View test results 67 | 68 | The backstop commands 'backstop remote' and 'backstop openReport' do not work in this setup. 69 | 70 | But there is a host command that will open the latest test report in your default browser: 71 | 72 | ```shell 73 | ddev backstop-results 74 | ``` 75 | 76 | Alternatively open the generated HTML-Report with your browser, e.g.: 77 | 78 | ```shell 79 | open tests/backstop/backstop_data/_mytestproject_/html_report/index.html 80 | ``` 81 | 82 | ## Changes to the original docker image 83 | 84 | The backstopjs docker image is extended with some functions using a custom docker build, see [Dockerfile](backstopBuild/Dockerfile) 85 | and uses a custom [entrypoint](backstopBuild/entrypoint.sh). 86 | 87 | In the Dockerfile the following is added/changed: 88 | 89 | - add the custom entrypoint.sh to the image 90 | - delete the default 'node' user with uid 1000 and add current ddev user 91 | - install the [minimist](https://www.npmjs.com/package/minimist) npm package globally. This is not needed by default 92 | but very handy to parse command line args for more complex custom backstopjs configs. 93 | 94 | The entrypoint is responsible for: 95 | 96 | - add /etc/hosts entries for all hosts configured in the ddev web container automatically 97 | - add sleep command to keep the container running 98 | 99 | ## Advanced 100 | 101 | ### How to add additional hostnames? 102 | 103 | If you want to test hosts not configured in the web container, you need to use external_links in the service containers. 104 | For that add a file `docker-compose.external_links.yaml` to your project which should look like this: 105 | 106 | ```yaml 107 | services: 108 | backstop: 109 | external_links: 110 | - "ddev-router:myproject.ddev.site" 111 | - "ddev-router:myproject2.ddev.site" 112 | ``` 113 | 114 | See: [ddev FAQ: Can different projects communicate with each other?](https://ddev.readthedocs.io/en/latest/users/usage/faq/#features-requirements) 115 | 116 | 117 | ### Change backstop tests directory 118 | Per default the backstop directory containing backstop config etc. is expected in your project directory (besides the 119 | .ddev folder) in the directory *tests/backstop*. 120 | 121 | If you want to change that edit the file [docker-compose.backstop.yaml](docker-compose.backstop.yaml) and 122 | change the line in volumes to the path you want to use, move the files to the new directory and restart ddev. 123 | 124 | Make sure to remove the #ddev-generated line from the file to prevent ddev from making changes to it. 125 | -------------------------------------------------------------------------------- /backstopBuild/Dockerfile: -------------------------------------------------------------------------------- 1 | #ddev-generated 2 | ARG BASE_IMAGE 3 | FROM $BASE_IMAGE 4 | 5 | # Add custom entrypoint 6 | COPY ./entrypoint.sh /entrypoint.sh 7 | RUN chmod +x /entrypoint.sh 8 | 9 | # delete the default 'node' user with uid 1000 and add current ddev user 10 | ARG username 11 | ARG uid 12 | ARG gid 13 | RUN userdel -r node 14 | RUN (groupadd --gid $gid "$username" || groupadd "$username" || true) && (useradd -l -m -s "/bin/bash" --gid "$username" --comment '' --uid $uid "$username" || useradd -l -m -s "/bin/bash" --gid "$username" --comment '' "$username" || useradd -l -m -s "/bin/bash" --gid "$gid" --comment '' "$username" || useradd -l -m -s "/bin/bash" --comment '' $username ) 15 | 16 | # Add sudo and sudoers in manner similar to other ddev containers 17 | RUN apt update && apt install -y sudo; apt clean -qq && rm -rf /var/lib/apt/lists/*; echo "ALL ALL=NOPASSWD: ALL" > /etc/sudoers.d/ddev-backstop && chmod 440 /etc/sudoers.d/ddev-backstop 18 | 19 | RUN npm install -g minimist 20 | 21 | # Install playwright browsers 22 | RUN npx playwright install-deps && npm cache clean --force; apt clean -qq && rm -rf /var/lib/apt/lists/* 23 | -------------------------------------------------------------------------------- /backstopBuild/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #ddev-generated 3 | 4 | routerIp=$(getent hosts ddev-router | awk '{ print $1 }') 5 | 6 | # Add entries to /etc/hosts for each DDEV_HOSTNAME (all hostnames in the web container) 7 | if [ -n "$routerIp" ]; then 8 | OIFS=$IFS 9 | IFS=',' 10 | for i in $DDEV_HOSTNAME; do 11 | echo "Add to /etc/hosts: routerIp $i" 12 | sudo sh -c "echo $routerIp $i >> /etc/hosts" 13 | done 14 | IFS=$OIFS 15 | fi 16 | 17 | sleep infinity 18 | -------------------------------------------------------------------------------- /commands/backstop/backstop: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #ddev-generated 4 | 5 | ## Description: Run backstop 6 | ## Usage: backstop [args] 7 | ## Example: "ddev backstop version" 8 | ## ExecRaw: true 9 | 10 | if [ "$1" == "openReport" -o "$1" == "remote" ]; then 11 | echo "This does not work for backstop in ddev. See ddev backstop-results command." 12 | exit 1 13 | fi 14 | 15 | NODE_PATH="/usr/local/lib/node_modules/" backstop "$@" 16 | -------------------------------------------------------------------------------- /commands/host/backstop-results: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #ddev-generated 4 | 5 | ## Description: Launch a browser with latest backstop results 6 | ## Usage: backstop-results 7 | ## Example: "ddev backstop-results" 8 | 9 | case $OSTYPE in 10 | linux-gnu) 11 | xdg-open ${DDEV_APPROOT}/tests/backstop/backstop_data/html_report/index.html 12 | ;; 13 | "darwin"*) 14 | open ${DDEV_APPROOT}/tests/backstop/backstop_data/html_report/index.html 15 | ;; 16 | "win*"* | "msys"*) 17 | start ${DDEV_APPROOT}/tests/backstop/backstop_data/html_report/index.html 18 | ;; 19 | esac 20 | -------------------------------------------------------------------------------- /docker-compose.backstop.yaml: -------------------------------------------------------------------------------- 1 | #ddev-generated 2 | 3 | services: 4 | # This is the service name used when running ddev commands accepting the 5 | # --service flag. 6 | backstop: 7 | # This is the name of the container. It is recommended to follow the same 8 | # name convention used in the main docker-compose.yml file. 9 | container_name: ddev-${DDEV_SITENAME}-backstop 10 | build: 11 | context: './backstopBuild' 12 | args: 13 | BASE_IMAGE: backstopjs/backstopjs:6.3.25 14 | username: $USER 15 | uid: $DDEV_UID 16 | gid: $DDEV_GID 17 | image: backstopjs/backstopjs:6.3.25-${DDEV_SITENAME}-built 18 | user: '$DDEV_UID:$DDEV_GID' 19 | # Add init to reap Chrome processes, as noted at 20 | # https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-in-docker 21 | init: true 22 | entrypoint: [ /entrypoint.sh ] 23 | volumes: 24 | - ../tests/backstop:/src 25 | - .:/mnt/ddev_config:ro 26 | shm_size: 1gb 27 | environment: 28 | DDEV_HOSTNAME: $DDEV_HOSTNAME 29 | # These labels ensure this service is discoverable by ddev. 30 | labels: 31 | com.ddev.site-name: ${DDEV_SITENAME} 32 | com.ddev.approot: ${DDEV_APPROOT} 33 | networks: 34 | ddev_default: null 35 | default: null 36 | -------------------------------------------------------------------------------- /install.yaml: -------------------------------------------------------------------------------- 1 | name: ddev-backstopjs 2 | 3 | pre_install_actions: 4 | - test -d ${DDEV_APPROOT}/tests/backstop || mkdir -p ${DDEV_APPROOT}/tests/backstop 5 | - test -f "${DDEV_APPROOT}/tests/backstop/.gitignore" || printf "## ddev-generated\n**/bitmaps_test\n**/html_report\n" > ${DDEV_APPROOT}/tests/backstop/.gitignore 6 | - grep -q "## ddev-generated" ${DDEV_APPROOT}/tests/backstop/.gitignore && printf "## ddev-generated\n**/bitmaps_test\n**/html_report\n" > ${DDEV_APPROOT}/tests/backstop/.gitignore || true 7 | 8 | 9 | # list of files and directories listed that are copied into project .ddev directory 10 | # Each file should contain #ddev-generated so it can be replaced by a later `ddev get` 11 | # if it hasn't been modified by the user. 12 | # DDEV environment variables can be interpolated into these filenames 13 | project_files: 14 | - docker-compose.backstop.yaml 15 | - backstopBuild/ 16 | - commands/backstop/backstop 17 | - commands/host/backstop-results 18 | 19 | post_install_actions: 20 | - echo "Install finished. Please restart ddev with 'ddev restart'" 21 | - echo "After that create your backstop config, e.g. run ddev backstop init." 22 | 23 | # Version constraint for DDEV that will be validated against the running DDEV executable 24 | # and prevent add-on from being installed if it doesn't validate. 25 | # See https://github.com/Masterminds/semver#checking-version-constraints for constraint rules. 26 | # Available with DDEV v1.23.4+, and works only for DDEV v1.23.4+ binaries 27 | ddev_version_constraint: '>= v1.24.3' 28 | -------------------------------------------------------------------------------- /tests/test.bats: -------------------------------------------------------------------------------- 1 | setup() { 2 | set -eu -o pipefail 3 | export DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )/.." 4 | export TESTDIR=~/tmp/test-addon-backstop 5 | mkdir -p $TESTDIR 6 | export PROJNAME=test-addon-backstop 7 | export DDEV_NON_INTERACTIVE=true 8 | ddev delete -Oy ${PROJNAME} >/dev/null 2>&1 || true 9 | cd "${TESTDIR}" 10 | ddev config --project-name=${PROJNAME} 11 | ddev start -y >/dev/null 12 | } 13 | 14 | teardown() { 15 | set -eu -o pipefail 16 | cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 ) 17 | ddev delete -Oy ${PROJNAME} >/dev/null 2>&1 18 | [ "${TESTDIR}" != "" ] && rm -rf ${TESTDIR} 19 | } 20 | 21 | @test "install from directory" { 22 | set -eu -o pipefail 23 | cd ${TESTDIR} 24 | echo "# ddev add-on get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 25 | ddev add-on get ${DIR} 26 | ddev restart 27 | 28 | # backstop is installed and can show its version 29 | ddev backstop version | grep 'Command "version" successfully executed' 30 | 31 | # openReport and remote commands show an error message 32 | set +o pipefail 33 | ddev backstop openReport | grep -q 'This does not work for backstop in ddev' 34 | ddev backstop remote | grep -q 'This does not work for backstop in ddev' 35 | } 36 | 37 | # bats test_tags=release 38 | #@test "install from release" { 39 | # set -eu -o pipefail 40 | # cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 ) 41 | # echo "# ddev add-on get drud/ddev-addon-template with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 42 | # ddev add-on get drud/ddev-addon-template 43 | # ddev restart >/dev/null 44 | # # Do something useful here that verifies the add-on 45 | # # ddev exec "curl -s elasticsearch:9200" | grep "${PROJNAME}-elasticsearch" 46 | #} 47 | -------------------------------------------------------------------------------- /tests/testdata/.gitmanaged: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmunz/ddev-backstopjs/b888cdb462d777a3e2781594295da3306881b97e/tests/testdata/.gitmanaged --------------------------------------------------------------------------------