Welcome to the Linux Foundation Forum!

Lesson 16 tests workaround

Hello, I am using Windows 11, node version 22.2.0 for LFW211 exam prep.

I kept getting AssertionError [ERR_ASSERTION]: tests should be successful (is package.json test script configured?) when running node validate.js for the first lab even though "uppercase.test.js" was correct (it included both assertion scenarios).

Adding "shell: true" to the spawnSync options resolved this issue. Posting in case anyone comes across this. Also is there an easier way to resolve?

const sp = spawnSync(
  process.platform === "win32" ? "npm.cmd" : "npm",
  ["test"],
  {
    stdio: "ignore",
    shell: true,
  }
);

James

Comments

  • Note this is using the Node test module, not tap. Tap did not work for me. Hopefully in the LFW211 exam we are allowed to choose between Node test module, tap or jest. I prefer the native test runner.

Categories

Upcoming Training