Skip to main content
rule official · GitHub

nodejs-javascript-vitest — GitHub Copilot rule: installation

This rule guides GitHub Copilot when generating Node.js JavaScript and Vitest tests. It applies to .js, .mjs, and .cjs files.

Install into GitHub Copilot · Manually: put the files in place All methods and platforms ↓
.github/instructions/nodejs-javascript-vitest.instructions.md
Open on GitHub

What nodejs-javascript-vitest does

The rule targets .js, .mjs, and .cjs files. It steers generated code toward ES2022 and ESM on Node.js 20+, favors built-in modules, and asks Copilot to check with the user before adding dependencies. For async work, it calls for async/await and recommends node:util's promisify instead of callbacks.

New features and bug fixes should come with Vitest tests, including checks for edge cases and errors. The original implementation should remain unchanged just to make tests easier. The guidance also favors functions over classes, undefined over null, and updating README.md for significant changes. Projects that do not use Node.js 20+ ESM may need different conventions.

What it helps with

  • write JavaScript for Node.js using ES2022 conventions
  • add Vitest coverage for new features and bug fixes
  • test edge cases and error handling
  • test existing code without changing it for convenience

Example prompts for the agent

  • Add a Node.js configuration reader and cover it with Vitest tests.
  • Fix error handling in the .mjs file and test its edge cases.
  • Review this JavaScript change against the project rules and update README.md if the change is significant.

How to install nodejs-javascript-vitest

Manually: put the files in place

.github/instructions/nodejs-javascript-vitest.instructions.md

The applyTo field sets which files it applies to

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about nodejs-javascript-vitest

How do I install nodejs-javascript-vitest in GitHub Copilot?

Add the rule file at .github/instructions/nodejs-javascript-vitest.instructions.md.

What does nodejs-javascript-vitest do?

It guides JavaScript code generation for Node.js and testing with Vitest. The rule applies to .js, .mjs, and .cjs files.

Which Node.js version does nodejs-javascript-vitest target?

Its guidance targets Node.js 20+ and ESM modules.

Source text

nodejs-javascript-vitest.instructions.md · MIT
---
description: "Guidelines for writing Node.js and JavaScript code with Vitest testing"
applyTo: '**/*.js, **/*.mjs, **/*.cjs'
---

# Code Generation Guidelines

## Coding standards
- Use JavaScript with ES2022 features and Node.js (20+) ESM modules
- Use Node.js built-in modules and avoid external dependencies where possible
- Ask the user if you require any additional dependencies before adding them
- Always use async/await for asynchronous code, and use 'node:util' promisify function to avoid callbacks
- Keep the code simple and maintainable
- Use descriptive variable and function names
- Do not add comments unless absolutely necessary, the code should be self-explanatory
- Never use `null`, always use `undefined` for optional values
- Prefer functions over classes

## Testing
- Use Vitest for testing
- Write tests for all new features and bug fixes
- Ensure tests cover edge cases and error handling
- NEVER change the original code to make it easier to test, instead, write tests that cover the original code as it is

## Documentation
- When adding new features or making significant changes, update the README.md file where necessary

## User interactions
- Ask questions if you are unsure about the implementation details, design choices, or need clarification on the requirements
- Always answer in the same language as the question, but use english for the generated content like code, comments or docs

© github · MIT · github/awesome-copilot

Similar IDE rules

All IDE rules for Testing and QA →

From the same set861

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor