๋ฐ๋ผํ๋ฉฐ ๋ฐฐ์ฐ๋ TDD ๊ฐ๋ฐ [2023.11 ์ ๋ฐ์ดํธ]
์ด ๊ฐ์๋ฅผ ํตํด์ ํ ์คํธ ์ฃผ๋ ๊ฐ๋ฐ(TDD)์ ์ด์ฉํ์ฌ Node.js ์ดํ๋ฆฌ์ผ์ด์ ์ ๋ง๋ค์ด ๋ด ๋๋ค.
์๊ฐ์ 1,211๋ช
๋์ด๋ ์ด๊ธ
์๊ฐ๊ธฐํ ๋ฌด์ ํ
- ๋ฏธํด๊ฒฐ
TypeError: user_model_1.default.create is not a function
ํ์ต์ค repository pattern์ ์ ์ฉํ์ฌ ํ ์คํธ๋ฅผ ์ ์ฉํด ๋ณด๋ ์ค TypeError: user_model_1.default.create is not a function ๋ผ๋ ์๋ฌ์ ๋ง์ฃผํ๊ฒ ๋์์ต๋๋ค.user.repository.ts</
node.jsmongodbexpresssupertesttddjestmongoose์ํํธ์จ์ด-ํ ์คํธ์์ง์
ใป
0
242
1
- ๋ฏธํด๊ฒฐ
์๋ฌ ์ฒ๋ฆฌ๋ฅผ ์ํ ๋จ์ํ ์คํธ ์์ฑ
์๋ฌ ์ฒ๋ฆฌ๋ฅผ ์ํ ๋จ์ํ ์คํธ ์์ฑ ๊ฐ์ ๋ด์ฉ ์ค ์ดํด๊ฐ ๊ฐ์ง ์๋ ๋ถ๋ถ์ด ์๊ฒจ ๊ธ ๋จ๊น๋๋ค.errorMessage ์ message ๋ด์ฉ์ description property missing ์๋ฌ์ ๋๋ค. ๊ทธ๋ ๋ค๋ฉด ํ ์คํธ ์ํฉ์์ ํฌ์คํธ๋งจ๊ณผ ๋์ผํ๊ฒ d
node.jsmongodbexpresssupertesttddjestmongoose์ํํธ์จ์ด-ํ ์คํธce ce
ใป
0
330
1
- ๋ฏธํด๊ฒฐ
res.status(201) ๋ถ๋ถ์์ typeerror๊ฐ ๋ฐ์ํฉ๋๋ค
์๋ฌ๋ฉ์์ง: TypeError: Cannot read properties of undefined (reading 'status')res.status(200); ํด๋น ์ฝ๋์์ ๋ฐ์ํ๋ ์๋ฌ์ธ๋ฐ ๊ฐ์ฌ๋์ด ์ฝ๋๋๋ฆฌ์ค๋๋ ํด๋น ์๋ฌ๊ฐ ๋ฐ์ํ์ง ์๋๋ฐ ์ p
node.jsmongodbexpresssupertesttddjestmongoose์ํํธ์จ์ด-ํ ์คํธkjyong702
ใป
0
374
1
- ๋ฏธํด๊ฒฐ
๋ฐ๋ผํ๋ฉฐ ๋ฐฐ์ฐ๋ TDD ๊ฐ๋ฐ [2023.11 ์ ๋ฐ์ดํธ] ๊ฐ์ ์ง๋ฌธ
๋ฐ๋ผํ๋ฉฐ ๋ฐฐ์ฐ๋ TDD ๊ฐ๋ฐ [2023.11 ์ ๋ฐ์ดํธ]2023.11 ์ ๋ฐ์ดํธ๋ผ๊ณ ๋์ด ์๋๋ฐ, ์ด๊ฒ ์ ๋ฐ์ดํธ
node.jsmongodbexpresssupertesttddjestmongoose์ํํธ์จ์ด-ํ ์คํธrhkdtjd_12
ใป
0
322
1
- ํด๊ฒฐ
[MAC] PORT:5000๋ฒ ๊ด๋ จ ์๋ฌ
์๋ ํ์ธ์. PORT 5000์ผ๋ก ์ค์ ํ๋๋์ด๋ฏธ ์ฌ์ฉ์ค์ธ ํฌํธ๋ก ๋์ค๋๋ผ๊ตฌ์.ํน์ ๊ฐ์ ์ฆ์ ์์ผ์ ๋ถ ์์ผ์ค ์ ์์ ๊ฒ ๊ฐ์์ ๋จ๊ฒจ๋ก๋๋ค.๋งฅ ๊ธฐ์ค ์์คํ ์ค์ ์์ '์์ดํ๋ ์ด ์์ ' ์ ๊บผ์ฃผ๋ฉด 5000๋ฒ ํฌํธ ์ฌ์ฉํ ์ ์์ต
node.jsexpressseokpyo1110
ใป
0
261
0
- ๋ฏธํด๊ฒฐ
ํ ์คํธ๋ฅผ ์ํ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์์ฑํด์ผํ๋์?
์ด์ ๋จ๊ณ์์์ ๋ฐ์ดํฐ๋ฒ ์ด์ค์๊ฐ๋ฐ ๋จ๊ณ์์์ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ๋ถ๋ฆฌํ์ฌ ์ด์ํ๋ค๊ณ ํ๋ฉด,ํ ์คํธ๋ฅผ ์ํ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ ๋ง๋ค์ด์ผํ ๊น์?
node.jsmongodbexpresssupertesttddjestmongoosejy
ใป
0
397
1
- ๋ฏธํด๊ฒฐ
Postman ์ฌ์ฉ๋ฐฉ๋ฒ์ ๋ํด์
์๋ ํ์ธ์ Postman์ ์๋์ฐ์์ ๊น์์ ์ฐ๋ ค๊ณ ํ๋๋ฐ ์๊พธ๋ง ์ ์ ๋ก๊ทธ๊ฐ ์๋ชป๋์๋ค๊ณ ์๋ฌ๊ฐ ๋น๋๋ค. ๋ค์ ์๋ํด ๋ด์ผ ํ๋์? ์๋๋ฉด postman์ launch๋ถํฐ ํ๊ณ ๋์ ๊น์์ผ ํ๋์? ์ฐธ๊ณ ๋ก postman์ launchํ๊ณ ๋์ ๋ ๋ค์ ๋ค์ด๋ก๋ ์
node.jsmongodbexpresssupertesttddjestmongooseJung Ho Park
ใป
0
390
1
- ๋ฏธํด๊ฒฐ
jest.fn() ์ ํ ๋นํ ๋ ํ์ ์คํฌ๋ฆฝํธ์์ ์๋ฌ๊ฐ ๋ฐ์ํฉ๋๋ค.
Typescript๋ฅผ ์ฐ๋ฉด์ ๊ณต๋ถ์ค์ ๋๋ค. productModel.create = jest.fn();์ ์ฝ๋๋ฅผ ํ ๋นํ ๋<c
node.jsmongodbexpresssupertesttddjestmongoosejy
ใป
0
429
1
- ๋ฏธํด๊ฒฐ
๋ผ์ฐํฐ๋ฅผ ๋๋ฆด ๋
์๋ ํ์ธ์. ์ด์ ์๋ ค์ฃผ์ ๋๋ก ์ ์ดํ์์ ๋ค์ ํธ์งํ๊ณ npm run start๊น์ง ๋๋ฆฌ๋ ๊ฒ ๊น์ง๋ ์ ๋์์ต๋๋ค. ๊ทผ๋ฐ ๋ฌธ์ ๋ chrome์ <a target="_blank" rel="noopener noreferrer nofollow" href="http:
node.jsexpresssupertesttddjestJung Ho Park
ใป
0
347
1
- ํด๊ฒฐ
npm run start๋ฅผ ์คํํ ๋ ๋ถํฐ๊ฐ ์ด์ํฉ๋๋ค.
์๋ ํ์ธ์ ๋ฐฉ๊ธ ๋ง์๋๋ ธ๋ค์ํผ, ์ค์นํ๋ ๊ฑฐ๊น์ง๋ ๊ธฐ๊ธฐ๊ฐ ๋ค๋ฅธ ๊ฒ ์ ์ธํ๊ณ ๋ ๋ณ ๋ค๋ฅธ ์ด์์ด ์์์ง๋ง, npm run start๋ฅผ ์คํํ ๋ ๋ถํฐ๊ฐ<img src="https://cdn.inflearn.com/public/files/posts/2344
node.jstddjestJung Ho Park
ใป
1
427
1
- ๋ฏธํด๊ฒฐ
node.js์ ๋ํ ์ด์์
์๋ ํ์ธ์. ์ด์ ๊ฐ์์์ ์๋ ค์ฃผ์ ๋๋ก node.js๋ฅผ ์ค์นํ๊ณ npm init, npm install express mongoose --save, npm install jest supertest node-mocks-http --save-dev๊น์ง ์ค์นํด์ ์คํ๊น
node.jsmongodbexpresssupertesttddjestmongooseJung Ho Park
ใป
0
449
1
- ๋ฏธํด๊ฒฐ
nodemocks ์ค๋ฅ๋๋๊น ๋บด๊ณ ์ค์นํ์ ์
npm i jest supertest --save-devnpm install --save-dev node-mocks-http<a target="_blank" rel="noopener noreferrer nofollow" href="htt
node.jsnodejssupertestmongodbexpresstddjestmongoose๊ธฐ์ ๋๋ฏธ
ใป
1
401
1
- ๋ฏธํด๊ฒฐ
Node.js ์ฑ์ ํ ์คํธํ๊ธฐ ์ํ Jest ์ค์ ๋ถ๋ถ..
jest.config.js ํ์ผ์ ์์ฑ ํด์ฃผ์ง ์์๋๋ฐ๋npm test ํ์ ๋ ๋ชฝ๊ตฌ์ค ๊ด๋ จ ์๋ฌ ๋ฉ์ธ์ง๊ฐ ๋์ค์ง ์๋ ์ด์ ๋ ๋ญ๊น์?
mongoosejestsupertestmongodbnodejsexpresstddalice
ใป
0
266
0
- ํด๊ฒฐ
models ํ์ผ๋ง ์ฒซ๋ฒ์งธ ๊ธ์๋ฅผ ๋๋ฌธ์๋ก ํด์ฃผ๋ ์ด์
models ํ์ผ๋ง Product.js ๋ก ์ฒซ๋ฒ์งธ ๊ธ์๋ฅผ ๋๋ฌธ์๋ก ํด์ฃผ๋ ์ด์ ๊ฐ ์๋์ง ๊ถ๊ธํฉ๋๋ค.
expresssupertesttddnodejsmongodbjestmongoosealice
ใป
0
291
1
- ๋ฏธํด๊ฒฐ
mongodb project ๋ฐ cluster๊ด๋ จ
์๋ ํ์ธ์! ๊ฐ์ ์ ๋ฃ๊ณ ์์ต๋๋ค. <div
mongodbmongooseexpresstddnodejssupertestmongodbjestmongoosegudwls5925
ใป
0
320
0
- ๋ฏธํด๊ฒฐ
๋ฌด์กฐ๊ฑด failure case ๋ก ๋์ด๊ฐ์๋ ๋ถ๋ค
์ ๋ฒ์ ์ด์์ธ์ง๋ ๋ชจ๋ฅด๊ฒ ์ผ๋, send ๋ผ๋ ์น๊ตฌ๊ฐ req.body ์์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ฃผ๋ ์ญํ ์ ํ๋๋ฐ ์ด๊ฒ undefined ๋ก ์ธ์๋๋ ๋ฌธ์ ๊ฐ ์์์ต๋๋ค.๊ทธ๋์ ๋ฌด์กฐ๊ฑด invalid case ์ ํด๋นํ๋ ์ด์๋ ๋ค์ ์ ํ ์ผ๋ก
expressnodejssupertesttddmongodbjestmongooseunchaptered
ใป
2
252
1
- ๋ฏธํด๊ฒฐ
์ฌ๋ ค๋ ES6 Express Jest Boilerplate Template ์ผ๋ก ๊ฐ๋ฐ ์ค์ด์ ๋ถ๋ค...
์๋์ฒ๋ผ ์์ฑํ์๋ฉด ๋ฉ๋๋ค. import * as productsController from '../../src/products/products.controller'; export const
nodejstddmongodbsupertestexpressjestmongooseunchaptered
ใป
0
232
0
- ๋ฏธํด๊ฒฐ
ES6 ์ฌ์ฉํ๊ณ ์ถ์ ๋ถ๋ค...
์ ๋ง ๊ทธ๋ฐ๊ฑด์ง ๋ชจ๋ฅด๊ฒ ์ง๋ง ์๋ ํ๊ฒฝ์์ jest.fn() is not function ์๋ฌ๊ฐ ๋ฐ์ํ๊ณ ์์ต๋๋ค. 1. Express.JS ์ฌ์ฉ ์ค 2. ES6 ๋ฌธ๋ฒ์ ์ฌ์ฉ ์ค 3. package.json ์ "typ
jestmongoosenodejssupertestmongodbtddexpressunchaptered
ใป
1
354
0
- ๋ฏธํด๊ฒฐ
Jest did not exit one second after the test run has completed. ์ด์
์๋ ํ์ธ์!! npm test๋ฅผ ํ๋ฉด ๋๋ถ๋ถ์ ํญ์ ๋ค์๊ณผ ๊ฐ์ ๋ฉ์ธ์ง๊ฐ ๋์ค๋๋ฐ์, >>>>>Ran all test suites. Jest did not exit one s
nodejsmongodbtddsupertestexpressmongoosejestํน๋ณํ ์ง๋ ์ด
ใป
0
3,023
3
- ๋ฏธํด๊ฒฐ
์ ์ธ์๋ค๊ฐ ํจ์ ์๋ง๋ค์ด๋ ํฌ์คํธ๋งจ์์๋ ์๋ฌ๋ฉ์ธ์ง๊ฐ ๋์ค๋ ๊ฒ์ธ๊ฐ์?
<h3 class="type-pla
expressmongodbnodejstddsupertestmongoosejestํน๋ณํ ์ง๋ ์ด
ใป
0
289
2






