American British Translator: functional test not succeeding?

Tell us what’s happening:

  1. My functional test keeps failing locally for
Functional Tests
       "POST" to /api/translate
         POST with text and locale fields populated:

      Uncaught AssertionError: expected { Object (text, translation) } to deeply equal { Object (text, translation) }
      + expected - actual

       {
      -  "text": "'Mangoes are my favorite fruit.'"
      -  "translation": "'Mangoes are my <span class=\"highlight\">favourite</span> fruit.'"
      +  "text": "Mangoes are my favorite fruit"
      +  "translation": "Mangoes are my <span class='highlight'>favourite</span> fruit."
       }

Your code so far
API route looks like:

app.route('/api/translate')
    .post((req, res) => {
      let locale = req.body.locale;
      let text = req.body.text;

      if (locale == undefined ||text == undefined) {
        return res.json({error:'Required field(s) missing'});
      }
      if (text == ''){
        return res.json({error: 'No text to translate' })
      }
      var possibleLocale = ['american-to-british', 'british-to-american'];
      if (possibleLocale.indexOf(locale) == -1) {
        return res.json({ error: 'Invalid value for locale field' });
      }

      let output = translator.translate(text,locale);
      if (output === text) {
        output = "Everything looks good to me!";
      }

      return res.json({
        text: text, 
        translation: output
      });
    });

2. On submitting my app on the Project page, I am getting 2 errors

frame-runner.js:100 Error: expected { status: 'unavailable' } to be an array
    at eval (eval at <anonymous> (frame-runner.js:84), <anonymous>:1:496)

Not sure why the unit test would also fail when they are running okay locally. Trying again after a while made all the unit tests pass atleast.
Your browser information:

Link to repl: https://project-american-british-english-translator.mandeep147.repl.co

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36.

Challenge: American British Translator

Link to the challenge:

Looks like output for Test 1 in Functional test is wrong. instead of

const output = {
   text: "Mangoes are my favorite fruit", 
   translation: "Mangoes are my <span class='highlight'>favourite</span> fruit."
};

output.text should end with a full stop .
and manually handling double quotes for Test 1 did the trick.

1 Like