Skip to content

js-v9 Implement A Queue lab tests should not be inter-dependant #66919

@hbar1st

Description

@hbar1st

Describe the Issue

I noticed that the Implement a Queue lab in the javascript-v9 certification has tests that are inter-dependant. An example of such a test is this one:

enqueue function should add an element to the back of the queue.

const queue = initQueue();
enqueue(queue, 'first');
enqueue(queue, 'second');
assert.strictEqual(front(queue), 'first');
assert.strictEqual(size(queue), 2);

In order to test enqueue, this test relies on two other functions being correct (front and size).
This means that if someone is working on just writing enqueue and testing their code, they will receive an error/hint which is not helpful to them at all.

Instead of writing the code this way, the test should independently confirm the contents and order of the queue.

An example of a forum question that bought this issue to light is this one:
https://forum.freecodecamp.org/t/implement-a-queue-implement-a-queue/785711?u=hbar1st

Affected Page

https://www.freecodecamp.org/learn/javascript-v9/lab-implement-a-queue/implement-a-queue

Your code

function initQueue() {
  return {
    collection: []
  };
}

function print(queue) {
  console.log(queue.collection);
}

function enqueue(queue, element) {
 queue.collection.push(element);
}

function dequeue(queue) {
 return  queue.collection.shift()
}

Expected behavior

The tests for enque and dequeue should not depend on the functions for size and front being completed.
Or if this is absolutely necessary, the instructions in the test should clearly say that the test for enque and dequeue requires the other two functions to be provided.

Screenshots

No response

System

N/A

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    js v9 certThis is for the JS V9 certification.scope: curriculumLessons, Challenges, Projects and other Curricular Content in curriculum directory.status: waiting triageThis issue needs help from moderators and users to reproduce and confirm its validity and fix.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions