npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@orderlycode/nest-test-tools

v0.1.1

Published

1. 모듈을 테스트 할때는 moduleTest 를 사용한다.

Downloads

67

Readme

nest-test-tools

  1. 모듈을 테스트 할때는 moduleTest 를 사용한다.
describe("test", () => {
  const test = moduleTest(AppModule)
  // 여기서 바로 사용 가능
  // 내부적으로 automock을 사용한다.
  const dependencyService = context.get(DependencyService);
  // 주의 dependencyService는 모두 beforeEach후에 초기화 된다.
})
  1. 유닛 테스트 할때는 unitTest 를 사용한다.
describe("test", () => {
  // 테스트마다 다시 setup된다. (beforeEach)
  const test = moduleTest(AppModule)
  // 여기서 바로 사용 가능, constructor에 있는 것만 쓸 수 있다.
  // 내부적으로 automock을 사용한다.
  const service = context.unit;
  const dependencyService = context.get(DependencyService);
  // 주의 service, dependencyService는 모두 beforeEach후에 초기화 된다.
})
  1. mocking이 필요하다면 가져다 쓴다.
// <jestRootDir>/__mocks__/bcryptjs.ts
export * from '@orderlycode/nest-test-tools/dist/mocks/bcryptjs';
// <jestRootDir>/__mocks__/@nestjs/typeorm.ts
export * from '@orderlycode/nest-test-tools/dist/mocks/@nestjs/typeorm';

테스트 도구

jest setupAfterEnv 파일 내에 아래 내용을 추가한다.

import '@orderlycode/nest-test-tools/dist/register';

이것은 .env.test 파일을 로드하고, nock을 통해 네트워크를 차단시키며 (supertest를 위한 127.0.0.1은 허용), context를 삽입한다.

nock 네트워크 활용

네트워크 데이터 수집 (테스트가 들어있는 폴더의 _recorded폴더에 저장됨)

import {record} from '@orderlycode/nest-test-tools';

describe('test', () => {
  record('test', () => {
    // 네트워크 콜
  })
})

수집된 데이터 사용하여 테스트

import {recorded} from '@orderlycode/nest-test-tools';

describe('test', () => {
  recorded('test', () => {
    // 네트워크 콜
  })
})