Bom dia é estou tento um probleminha e não sei no que estou errando ou o que há de errado, ficarei muito grato se alguém me der uma luz, comparei com os test feito e está a mesma coisa revisei todo o codigo achei que era alguma coisa que escrevi errado. O que eu fiz:
- Reescrevi o codigo, comparando com o existente da versão final.
 - Apaguei e reinstalei o node modules e dei um npm clean .
 - Achei que era a function de tratar erro, mas não enxerguei erro de sintaxe .
 
Link do repo com minha versão: https://github.com/matheusrcruz/NodeJs/tree/test
index aonde fica a função tratar erro:
const chalk = require('chalk');
const fs = require('fs');
function extraiLinks(texto) {
  const regex = /\[([^\]]*)\]\((https?:\/\/[^$#\s].[^\s]*)\)/gm;
  const arrayResultados = [];
  let temp;
  while((temp = regex.exec(texto)) !== null) {
    arrayResultados.push({ [temp[1]]: temp[2] })
  }
  return arrayResultados.length === 0 ? 'não há links' : arrayResultados;
}
function trataErro(erro) {
  throw new Error(chalk.red(erro.code, 'não há arquivo no caminho'));
}
async function pegaArquivo(caminhoDoArquivo) {
  const encoding = 'utf-8';
  try {
    const texto = await fs.promises.readFile(caminhoDoArquivo, encoding)
    return extraiLinks(texto);
  } catch(erro) {
    trataErro(erro);
  }
}
module.exports = pegaArquivo;Exception :
$ npm run test
NodeJS@1.0.0 test C:\labs\NodeJS jest ./test
FAIL test/index.test.js pegaArquivo:: √ deve ser uma função (2 ms) × deve retornar array com resultados (2 ms)
● pegaArquivo:: › deve retornar array com resultados
ENOENT não há arquivo no caminho
  13 |
  14 | function trataErro(erro) {
> 15 |   throw new Error(chalk.red(erro.code, 'não há arquivo no caminho'));
     |         ^
  16 | }
  17 |
  18 | async function pegaArquivo(caminhoDoArquivo) {
  at trataErro (index.js:15:9)
  at pegaArquivo (index.js:24:5)
  at Object.<anonymous> (test/index.test.js:13:27)Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 passed, 2 total
Snapshots:   0 total
Time:        0.337 s, estimated 1 s
Ran all test suites matching /.\test/i.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! NodeJS@1.0.0 test: jest ./test
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the NodeJS@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\home\AppData\Roaming\npm-cache_logs\2021-10-25T00_52_25_857Z-debug.log