-
Notifications
You must be signed in to change notification settings - Fork 2
[Beginner] Create a Project
- Open a terminal.
cd
into a directory/folder wherein you'd like to keep your projects and defineNAME
.
cd $TUT
NAME=sample
✔️ In this case, sample
will be our directory name.
- Initiate project in the directory.
mkdir $NAME
cd $NAME
npm init -y
npm init ava
npm i -D typescript ts-node
mkdir src
mkdir test
✔️ This creates the directory sample and moves into it. Then it initializes the node package manager, sets up AVA, and the language Typescript. Lastly, it creates two empty directories src
and test
for all of our code.
- Once done, open up Visual Studio Code.
code .
✔️ This will launch VS Code with the sample
file as defined in Step 1.
- Add test runner config (AVA settings in
package.json
). You can also simply type inava
which will automatically show an option to fill in the snippets you need if you already haveava-recipes
installed.
"ava": {
"files": [
"test/**/*.test.ts"
],
"extensions": [
"ts"
],
"require": [
"ts-node/register"
]
},
✔️ Go to extensions on VS Code and look for ava-recipes
and ava-launch
then install them. The former will allow you to easily add snippets by typing the keywords. It automatically fills in the code that you need. The latter is for debugging and running single AVA tests easily using multiple npm scripts. You will need it later.
- Open a bash terminal within VS Code to add the language config files.
TS_CONFIG=https://raw.githubusercontent.com/YizYah/testingWebinar/main/tsconfig.json
wget $TS_CONFIG -O tsconfig.json
INT_CONFIG=https://raw.githubusercontent.com/YizYah/testingWebinar/main/int-tests.config.cjs
wget $INT_CONFIG -O int-tests.config.cjs
GIT_IGNORE=https://raw.githubusercontent.com/YizYah/testingWebinar/main/.gitignore
wget $GIT_IGNORE -O .gitignore
✔️ The following files will show up: tsconfig.json
.gitignore
int-tests.config.cjs
- Prerequisite: node should be installed
❗ Need help? Reach out to us on NoStack's Discord Server/Community. We'll make sure to respond to you as soon as possible!