Description
The URL Shortener Microservice project Test #3 (“When you visit /api/shorturl/<short_url>, you will be redirected to the original URL”) fails with an error in the test runner, not in my code.
Error Message
Error: redirected is not implemented yet
at o (dom-test-evaluator.js:2:64933)
at get redirected (dom-test-evaluator.js:2:65501)
The Problem
Looking at the FCC test code:
const getResponse = await fetch(url + '/api/shorturl/' + shortenedUrlVariable);
if (getResponse) {
const { redirected, url } = getResponse;
assert.isTrue(redirected); // <-- This fails
assert.strictEqual(url, fullUrl);
}
The test uses response.redirected property which is not implemented in the FCC test runner’s sandboxed environment.
Proof My Code Works
Testing with curl shows correct 302 redirect:
$ curl -I https://my-url-shortener.onrender.com/api/shorturl/1
HTTP/1.1 302 Found
Location: https://www.google.com
Additional Info
-
FCC’s own example URL also fails this test when submitted
-
Tests 1, 2, and 4 pass correctly
-
Browser: Chrome (latest)
-
The redirect actually works when visiting the URL manually
Expected Behavior
The test should pass when the API correctly returns a 302 redirect with proper Location header.
Suggested Fix
Either:
-
Implement
response.redirectedin the test runner -
Or change the test to check for 3xx status code and Location header instead
My Project: FCC-Backend/projects/url-shortener at main · bhavyup/FCC-Backend · GitHub