From e3922c19ce07478b9be65fd281930d9d41048c5c Mon Sep 17 00:00:00 2001 From: yasaichi Date: Mon, 8 Jan 2024 09:53:37 +0900 Subject: [PATCH] Improve the way of testing with updates on Deno v1.39.2 --- deno.json | 13 ------------- deno.jsonc | 19 +++++++++++++++++++ deno.lock | 4 ++-- src/app.controller.test.ts | 6 +----- test/app.e2e_test.ts | 14 +------------- 5 files changed, 23 insertions(+), 33 deletions(-) delete mode 100644 deno.json create mode 100644 deno.jsonc diff --git a/deno.json b/deno.json deleted file mode 100644 index acb7f03..0000000 --- a/deno.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "emitDecoratorMetadata": true - }, - "fmt": { - "include": ["src/", "test/"], - "singleQuote": true - }, - "lint": { - "include": ["src/", "apps/", "libs/", "test/"] - }, - "unstable": ["byonm"] -} diff --git a/deno.jsonc b/deno.jsonc new file mode 100644 index 0000000..e69b693 --- /dev/null +++ b/deno.jsonc @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "emitDecoratorMetadata": true + }, + "fmt": { + "include": ["src/", "test/"], + "singleQuote": true + }, + // NOTE: Don't use the standard library or any third party modules of Deno + // as possible because we'd like to keep the room to go back to Node.js + // at any time. + "imports": { + "testing/": "https://deno.land/std@0.211.0/testing/" + }, + "lint": { + "include": ["src/", "apps/", "libs/", "test/"] + }, + "unstable": ["byonm"] +} diff --git a/deno.lock b/deno.lock index d32564b..f23c015 100644 --- a/deno.lock +++ b/deno.lock @@ -1,7 +1,7 @@ { "version": "3", "remote": { - "https://deno.land/std@0.210.0/testing/_test_suite.ts": "30f018feeb3835f12ab198d8a518f9089b1bcb2e8c838a8b615ab10d5005465c", - "https://deno.land/std@0.210.0/testing/bdd.ts": "c41f019786c4a9112aadb7e5a7bbcc711f58429ac5904b3855fa248ba5fa0ba6" + "https://deno.land/std@0.211.0/testing/_test_suite.ts": "f10a8a6338b60c403f07a76f3f46bdc9f1e1a820c0a1decddeb2949f7a8a0546", + "https://deno.land/std@0.211.0/testing/bdd.ts": "3cbd17bd35f629a76ce63446238dfb4632240dd46b3b205027c45fa3dd67e554" } } diff --git a/src/app.controller.test.ts b/src/app.controller.test.ts index 411de55..8871ced 100644 --- a/src/app.controller.test.ts +++ b/src/app.controller.test.ts @@ -1,10 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { - beforeEach, - describe, - it, -} from 'https://deno.land/std@0.210.0/testing/bdd.ts'; import assert from 'node:assert'; +import { beforeEach, describe, it } from 'testing/bdd.ts'; import { AppController } from './app.controller.ts'; import { AppService } from './app.service.ts'; diff --git a/test/app.e2e_test.ts b/test/app.e2e_test.ts index ed2bb4d..09fa3d6 100644 --- a/test/app.e2e_test.ts +++ b/test/app.e2e_test.ts @@ -1,21 +1,9 @@ import { INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { - afterEach, - beforeEach, - describe, - it, -} from 'https://deno.land/std@0.210.0/testing/bdd.ts'; -import { ClientRequest } from 'node:http'; import request from 'supertest'; +import { afterEach, beforeEach, describe, it } from 'testing/bdd.ts'; import { AppModule } from '../src/app.module.ts'; -// NOTE: Delete this patch when the following issue is resolved: -// https://github.com/denoland/deno/issues/18316 -ClientRequest.prototype.setNoDelay = function (noDelay) { - this.socket?.setNoDelay?.(noDelay); -}; - describe('AppController (e2e)', () => { let app: INestApplication;