Skip to content

Commit

Permalink
fix(test): Github Actions上で外部サイトへの取得を行うテストをスキップするように
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Nov 11, 2024
1 parent 1b541a1 commit efe0904
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
pnpm build
- name: Test
run: |
pnpm test
SKIP_NETWORK_TEST=true pnpm test
13 changes: 11 additions & 2 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { Agent as httpAgent } from 'node:http';
import { Agent as httpsAgent } from 'node:https';
import { expect, test, describe, beforeEach, afterEach } from '@jest/globals';
import { expect, test, describe, beforeEach, afterEach, xtest } from '@jest/globals';
import fastify, { type FastifyInstance } from 'fastify';
import { summaly } from '../src/index.js';
import { StatusError } from '../src/utils/status-error.js';
Expand All @@ -36,6 +36,15 @@ process.on('unhandledRejection', console.dir);

let app: FastifyInstance | null = null;

function skippableTest(name: string, fn: () => void) {
if (process.env.SKIP_NETWORK_TEST === 'true') {
console.log(`[SKIP] ${name}`);
xtest(name, fn);
} else {
test(name, fn);
}
}

afterEach(async () => {
if (app) {
await app.close();
Expand Down Expand Up @@ -76,7 +85,7 @@ test('basic', async () => {
});
});

test('Stage Bye Stage', async () => {
skippableTest('Stage Bye Stage', async () => {
// If this test fails, you must rewrite the result data and the example in README.md.

const summary = await summaly('https://www.youtube.com/watch?v=NMIEAhH_fTU');
Expand Down

0 comments on commit efe0904

Please sign in to comment.