Running tests locally is difficult to match with the CI
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3538439. -->
Reported by: [justafish](https://www.drupal.org/user/161058)
Related to !1376
>>>
<h3 id="overview">Overview</h3>
<ul>
<li>Multiple people are reporting different results locally than the CI</li>
<li>Multiple people are struggling to run the tests</li>
<li>There isn't a clear way that we should all be running our tests with the same environment</li>
<li><a href="https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes/include.drupalci.main.yml">Figuring out what the CI is doing requires going through a lot of indirection</a></li>
</ul>
<h3 id="proposed-resolution">Proposed resolution</h3>
<ul>
<li>Add some scripts for running tests locally along with clear documentation</li>
<li>Ensure the CI is running the same commands</li>
</ul>
<h3 id="resolution">Resolution</h3>
<ul>
<li>Added composer run phpunit in <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-2"><a href="https://www.drupal.org/project/canvas/issues/3538439" title="Status: Fixed">#3538439: Running tests locally is difficult to match with the CI</a></span>, improved in <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/canvas/issues/3585788" title="Status: Closed (fixed)">#3585788: Make it easier to run PHPUnit tests: enable `composer run phpunit` from Canvas root</a></span></li>
<li>A <code>tests/scripts/phpunit.sh</code> script was added that runs tests through Drupal core's run-tests.sh for parallel execution</li>
<li><code>composer run lint</code> added in <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-2"><a href="https://www.drupal.org/project/canvas/issues/3591245" title="Status: Fixed">#3591245: DX: Introduce `composer run lint` that runs PHPCS + PHPStan (sibling to `npm run lint`)</a></span></li>
<li>drupal.org GitLab template removed in <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3529128" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3529128</a></span></li>
<li>Documentation added to the <code>docs/testing</code> directory</li>
</ul>
> Related issue: [Issue #3539554](https://www.drupal.org/node/3539554)
> Related issue: [Issue #3516348](https://www.drupal.org/node/3516348)
> Related issue: [Issue #3540470](https://www.drupal.org/node/3540470)
issue