šŸš€ LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
šŸŽ“ COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///

Untitled Lesson

⚔ Total XP: 0|šŸ’» backend XP: 0

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

Select an unlocked node to view details root

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Common Pitfalls & Errors

The Error //

Naming test files without the recognized convention (e.g. userSpec.js instead of user.test.js)

// Wrong: silently skipped by default discovery // file: userSpec.js // Correct: matches default node:test discovery // file: user.test.js

The Solution //

node --test only auto-discovers files matching its default patterns (e.g. *.test.js, files under a test/ directory). A file named outside that convention is silently skipped — the run reports zero failures because it never found any tests to fail, giving a false sense of a passing suite.

The Error //

Expecting Jest-style matchers like toMatchObject or toHaveBeenCalledWith to exist in node:assert

// Wrong: not a real node:assert method // assert.toMatchObject(result, { id: 1 }); // Correct assert.deepStrictEqual(result, { id: 1, name: "Ada", active: true });

The Solution //

node:assert is intentionally minimal compared to Jest's expect() API — it has no toMatchObject-style partial matching. For structural comparisons, use assert.deepStrictEqual with a fully-specified expected object, or accept that some Jest idioms require slightly more verbose assertions in the native runner.

Continue Learning