Repository: freeCodeCamp/freeCodeCamp
File: e2e/output.spec.ts (TypeScript)

Code before:
    await page.goto(
      '/learn/front-end-development-libraries/jquery/target-html-elements-with-selectors-using-jquery'
    );
    await expect(
      page.getByRole('region', {
        name: translations.learn['editor-tabs'].console
      })
    ).toHaveText(outputTexts.default);

    await expect(
      page.getByRole('region', {
        name: translations.learn['editor-tabs'].console
      })
    ).not.toHaveText('ReferenceError: $ is not defined');
  });

  test('Custom output for JavaScript Objects set and map', async ({
    page,
    browserName
  }) => {
    await page.goto(
      '/learn/javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code'
    );
    await insertTextInCodeEditor({
      page,
      isMobile: false,
      text: 'const set = new Set(); set.add(1); set.add("set"); set.add(10); console.log(set);'
    });
    await expect(
      page.getByRole('region', {
        name: translations.learn['editor-tabs'].console
      })
    ).toContainText('Set(3) {1, set, 10}');

    await clearEditor({ browserName, page });

    await insertTextInCodeEditor({
      page,
      isMobile: false,
      text: 'const map = new Map(); map.set(1, "one"); map.set("two", 2); console.log(map);'
    });

    await expect(
      page.getByRole('region', {
        name: translations.learn['editor-tabs'].console
      })
    ).toContainText('Map(2) {1 => one, two => 2}');
  });
});


Review comment (suggestion):
```suggestion
      isMobile,
```
I don't think this should be hard-coded. Otherwise it will likely break if we run the tests on mobile browsers (which we should if they're quick enough).

Code after:
    });
    await expect(outputConsole).toBeVisible();
    await expect(outputConsole).toHaveText(outputTexts.default);
  });

  test('should contain syntax error output when var is entered in editor', async ({
    page,
    isMobile
  }) => {
    await insertTextInCodeEditor({ page, isMobile, text: 'var' });
    await expect(
      page.getByRole('region', {
        name: translations.learn['editor-tabs'].console
      })
    ).toHaveText(outputTexts.syntaxError);
  });

  test('should contain reference error output when var is entered in editor', async ({
    page,
    isMobile
  }) => {
    const referenceErrorRegex =
      /ReferenceError: (myName is not defined|Can't find variable: myName)/;
    await insertTextInCodeEditor({ page, isMobile, text: 'myName' });
    await expect(
      page.getByRole('region', {
        name: translations.learn['editor-tabs'].console
      })
    ).toHaveText(referenceErrorRegex);
  });

  test('should contain final output after test fail', async ({
    page,
    isMobile
  }) => {
    await runChallengeTest(page, isMobile);
    await expect(
      page.getByRole('region', {
        name: translations.learn['editor-tabs'].console
      })
    ).toHaveText(outputTexts.empty);
  });

  test('should contain final output after test pass', async ({
    page,
    isMobile
  }) => {
    const closeButton = page.getByRole('button', { name: 'Close' });

    await insertTextInCodeEditor({ page, isMobile, text: 'var myName;' });
    await runChallengeTest(page, isMobile);