-
-
Notifications
You must be signed in to change notification settings - Fork 23.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds several end-to-end tests that can be used to test whether the Vercel Preview deployment successfully returns the cards.
- Loading branch information
Showing
5 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Vercel Preview Tests | ||
on: | ||
deployment_status: | ||
|
||
jobs: | ||
e2e: | ||
name: Test Vercel Preview Deployment | ||
if: | ||
github.event_name == 'deployment_status' && | ||
github.event.deployment_status.state == 'success' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install dependencies | ||
run: npm ci | ||
env: | ||
CI: true | ||
- name: Run end-to-end tests. | ||
run: npm run test:e2e | ||
env: | ||
VERCEL_PREVIEW_URL: ${{ github.event.deployment_status.target_url }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
clearMocks: true, | ||
transform: {}, | ||
testEnvironment: "jsdom", | ||
coverageProvider: "v8", | ||
testMatch: ["<rootDir>/tests/E2E/**/*.test.js"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @file Contains end-to-end tests for the vercel preview instance. | ||
*/ | ||
import { describe } from "@jest/globals"; | ||
import axios from "axios"; | ||
|
||
describe("Fetch Cards", () => { | ||
let VERCEL_PREVIEW_URL; | ||
|
||
beforeAll(() => { | ||
VERCEL_PREVIEW_URL = process.env.VERCEL_URL; | ||
}); | ||
|
||
test("retrieve stats card", async () => { | ||
expect(VERCEL_PREVIEW_URL).toBeDefined(); | ||
await expect( | ||
axios.get(`${VERCEL_PREVIEW_URL}/api?username=anuraghazra`), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
test("retrieve language card", async () => { | ||
expect(VERCEL_PREVIEW_URL).toBeDefined(); | ||
await expect( | ||
axios.get(`${VERCEL_PREVIEW_URL}/api/top-langs/?username=anuraghazra`), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
test("retrieve WakaTime card", async () => { | ||
expect(VERCEL_PREVIEW_URL).toBeDefined(); | ||
await expect( | ||
axios.get(`${VERCEL_PREVIEW_URL}/api/wakatime?username=willianrod`), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
test("retrieve repo card", async () => { | ||
expect(VERCEL_PREVIEW_URL).toBeDefined(); | ||
await expect( | ||
axios.get( | ||
`${VERCEL_PREVIEW_URL}/api/pin/?username=anuraghazra&repo=github-readme-stats`, | ||
), | ||
).resolves.not.toThrow(); | ||
}); | ||
}); |