Skip to content

Latest commit

ย 

History

History
38 lines (28 loc) ยท 1.12 KB

passing-arguments-to-your-test-files.md

File metadata and controls

38 lines (28 loc) ยท 1.12 KB

์—ญ์ž์ฃผ

์ด ๋ฌธ์„œ๋Š” passing-arguments-to-your-test-files.md์˜ ํ•œ๊ตญ์–ด ๋ฒˆ์—ญ์ž…๋‹ˆ๋‹ค. ์ด๊ณณ์—์„œ AVA์˜ master ๋ธŒ๋žœ์น˜์™€ ์ด ๋ฌธ์„œ์˜ ์ฐจ์ด๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. (๋งŒ์•ฝ ์ฐจ์ด๊ฐ€ ์—†๋‹ค๋ฉด ๋ฌธ์„œ๊ฐ€ ์ตœ์‹  ๋ฒ„์ „์ž„์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค)


ํ…Œ์ŠคํŠธ ํŒŒ์ผ๋“ค์— ์ธ์ž(arguments) ๋„˜๊ฒจ์ฃผ๊ธฐ

ํ…Œ์ŠคํŠธ ํŒŒ์ผ์— ์ปค๋งจ๋“œ ๋ผ์ธ ์ธ์ž๋ฅผ ๋„˜๊ฒจ์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

-- argument terminator๋ฅผ ์‚ฌ์šฉํ•ด, AVA์˜ ์ธ์ž์™€ ๋‹น์‹ ์˜ ์ธ์ž๋ฅผ ๋ถ„๋ฆฌํ•˜๋„๋ก ํ•˜์„ธ์š”.

// test.js
import test from 'ava';

test('argv', t => {
	t.deepEqual(process.argv.slice(2), ['--hello', 'world']);
});
$ npx ava -- --hello world

๋งŒ์•ฝ npm test ์Šคํฌ๋ฆฝํŠธ ๋‚ด๋ถ€์—์„œ, AVA๋ฅผ ํ˜ธ์ถœํ•˜๋ ค๊ณ  ํ•˜๋Š” ๊ฒฝ์šฐ, ๋‘ ๊ฐœ์˜ -- argument terminators๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

{
	"scripts": {
		"test": "ava"
	}
}
$ npm test -- -- --hello world