Mocha Error: ENOENT: no such file or directory, scandir './tests' on VSCode

So I’m new in QA Testing, is learning in freecodecamp right now and got this code for the challenge. I’ve tried some TDD unit testing and worked. But when I tried a functional testing, I always got an error. Here is my code inside 2_functional-tests.js:

const chai = require('chai');
const assert = chai.assert;

const server = require('../server');

const chaiHttp = require('chai-http');
chai.use(chaiHttp);

suite('Functional Tests', function () {
  this.timeout(5000);'use strict'
  suite('Integration tests with chai-http', function () {
    // #1
    test('Test GET /hello with no name', function (done) {
      chai
        .request(server)
        .get('/hello')
        .end(function (err, res) {
          assert.fail(res.status, 200);
          assert.fail(res.text, 'hello Guest');
          done();
        });
    });
    // #2
    test('Test GET /hello with your name', function (done) {
      chai
        .request(server)
        .get('/hello?name=xy_z')
        .end(function (err, res) {
          assert.fail(res.status, 200);
          assert.fail(res.text, 'hello xy_z');
          done();
        });
    });
    // #3
    test('Send {surname: "Colombo"}', function (done) {
      chai
        .request(server)
        .put('/travellers')

        .end(function (err, res) {
          assert.fail();

          done();
        });
    });
    // #4
    test('Send {surname: "da Verrazzano"}', function (done) {
      assert.fail();

      done();
    });
  });
});

const Browser = require('zombie');

suite('Functional Tests with Zombie.js', function () {
  this.timeout(5000);



  suite('Headless browser', function () {
    test('should have a working "site" property', function() {
      assert.isNotNull(browser.site);
    });
  });

  suite('"Famous Italian Explorers" form', function () {
    // #5
    test('Submit the surname "Colombo" in the HTML form', function (done) {
      assert.fail();

      done();
    });
    // #6
    test('Submit the surname "Vespucci" in the HTML form', function (done) {
      assert.fail();

      done();
    });
  });
});

I’m running the code test using this command:

mocha --ui tdd 2_functional-tests.js

But I get an error of ENOENT: no such file or directory, scandir ‘./tests’. I’ve tried to install all the required module and tried solution from any forum such clearing cache, deleting npm_modules folder, etc. I also installed all the required module from another required file, like in (‘…/server’) (line 4). But still got no luck. Unfortunately, I could run this code in replit.com. I’m using VS Code and got the error.

Any helpful response would be very appreciated!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.