Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: netlify-edge-functions-test for PRs and jest tests #3229

Merged
merged 5 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/netlify-edge-functions-test.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: Run tests for netlify edge-functions

on:
workflow_dispatch
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to test netlify function this many times on each PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we calling in the actual netlify function while testing? Not sure, maybe @Shurtu-gal might help here.
Is that's not the case, then this is okay, since we do that number of times for jest tests also.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual netlify function is not called at all. Instead the logic is tested through mocking.

mf.install();
mf.mock("*", (req) => {
console.log(req.url);
if (req.url === metricURL) {
metricCalls++;
}
const body = {
url: req.url,
method: req.method,
headers: req.headers,
};
return new Response(JSON.stringify(body), {
status: 200,
headers: {
"Content-Type": "application/json",
},
});
});
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarification @Shurtu-gal
@akshatnema I think we can then go for running netlify function tests for every PR this number of times. Afterall, they are taking around 11 seconds


jobs:
netlify-tests:
strategy:
matrix:
deno-version: [1.30.0]
deno-version: [1.46.0]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Deno
uses: denolib/setup-deno@v2
uses: denoland/setup-deno@3a041055d2e2068f6e2c59904ee0ec2dfa9d9665
with:
deno-version: ${{ matrix.deno-version }}
- name: Test with Deno
run: deno test --allow-env --trace-ops

run: deno test --allow-env --trace-ops netlify/**/*.test.ts

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ cypress/videos
*storybook.log
/storybook-static/
coverage
deno.lock
Loading