codex-lv3-may-2025

Level Navigation: 1 (2ℹ️) 3 4 5 6 (7ℹ️) (8ℹ️) (9ℹ️) 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 (37ℹ️) 38⚡ 39⚡ 40⚡ 41⚡ 42 43⚡ 44⚡ 45 46 (47ℹ️)

Level 3: Set up the project

First, initialize your npm project and install Vitest:

npm init -y
npm install --save-dev vitest

Then, update your package.json to add the test script and set the module type:

{
  "type": "module",
  "scripts": {
    "test": "vitest"
  }
}
Show Me: What the full package.json might look like

When you run npm init -y, it creates a basic package.json (see [npm](/codex-lv3-may-2025/VOCABULARY_LIST.html#npm) for more on npm commands). After adding the type and scripts fields, your complete package.json might look like this:


{
  "name": "function-practice",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "vitest"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "vitest": "^1.0.0"
  }
}

Key points:

Now run the test command to verify Vitest is set up correctly (it will show no tests found, which is expected):

npm run test

🔍 Diving Deeper

Press q to quit the test runner when you’re done checking.

Key Terms