From 3be83e4dfa45738ed076b2040dfffa0f0d16adbb Mon Sep 17 00:00:00 2001 From: Rhys Evans <wheresrhys@gmail.com> Date: Fri, 19 Jul 2024 22:14:28 +0100 Subject: [PATCH] chore: add test-deploy workflow for docusaurus --- .github/workflows/test-deploy.yml | 26 +++++++++++++++++++ .../src/content/docs/API/Mocking/mock.md | 10 ++++--- 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/test-deploy.yml diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml new file mode 100644 index 00000000..993bdca5 --- /dev/null +++ b/.github/workflows/test-deploy.yml @@ -0,0 +1,26 @@ +name: Test deployment + +on: + pull_request: + branches: + - main + # Review gh actions docs if you want to further define triggers, paths, etc + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on + +jobs: + test-deploy: + name: Test deployment + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: 18 + cache: npm + + - name: Install dependencies + run: npm ci + - name: Test build website + run: npm run build -w docs diff --git a/docs/fetch-mock/src/content/docs/API/Mocking/mock.md b/docs/fetch-mock/src/content/docs/API/Mocking/mock.md index 93bb4793..04a49134 100644 --- a/docs/fetch-mock/src/content/docs/API/Mocking/mock.md +++ b/docs/fetch-mock/src/content/docs/API/Mocking/mock.md @@ -42,21 +42,24 @@ For complex matching (e.g. matching on headers in addition to url), there are 4 ```js fetchMock.mock({ url, headers }, response); ``` -This has the advantage of keeping all the matching criteria in one place. + +This has the advantage of keeping all the matching criteria in one place. 2. Pass in options in a third parameter e.g. ```js fetchMock.mock(url, response, { headers }); ``` -This splits matching criteria between two parameters, which is arguably harder to read. However, if most of your tests only match on url, then this provides a convenient way to create a variant of an existing test. + +This splits matching criteria between two parameters, which is arguably harder to read. However, if most of your tests only match on url, then this provides a convenient way to create a variant of an existing test. 3. Use a single object, e.g. ```js fetchMock.mock({ url, response, headers }); ``` -Nothing wrong with doing this, but keeping response configuration in a separate argument to the matcher config feels like a good split. + +Nothing wrong with doing this, but keeping response configuration in a separate argument to the matcher config feels like a good split. 4. Use a function matcher e.g. @@ -65,6 +68,7 @@ fetchMock.mock((url, options) => { // write your own logic }, response); ``` + Avoid using this unless you need to match on some criteria fetch-mock does not support. ## Examples