bug: Curriculum test regex does not cover some code formats
See original GitHub issueAffected page Affected page
Your code
passport.use(
new GithubStrategy(
{
clientID: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
callbackURL:
"https://myapplication.myId.repl.co/auth/github/callback",
},
(accessToken, refreshToken, profile, cb) => {
console.log(profile);
}
)
);
The callback url is redacted.
Expected behavior I expected this code to pass the tests. But it did not.
System (please complete the following information):
- Device: [Laptop]
- OS: [Ubuntu 20.4]
- Browser: [Opera]
- Version: [77]
Additional context
The third test GitHub strategy should be setup correctly thus far.
didn’t pass. So, I ran FCC on my local computer and checked the tests on the page. The first regex test is as follows:
assert.match(
data,
/passport\.use.*new GitHubStrategy/gi,
'Passport should use a new GitHubStrategy'
);
The regex won’t pass if new GitHubStrategy
is on a new line because .
matches all characters except for the new line.
When I replaced .
with [\s\S]
the tests passed.
So I think we should change this test to the following:
assert.match(
data,
/passport\.use[\s\S]*new GitHubStrategy/gi,
'Passport should use a new GitHubStrategy'
);
My reasoning is that the correctness of a solution should not depend on formatting. Especially when the formatting is not something very abnormal.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top GitHub Comments
Hi @aileenpalafox Are you sure you haven’t a false positive produced by the commented out
GithubStrategy
? Neither of the regexes can differentiate between commented and uncommented code.You’re totally right, @alirezaghey! I completely forgot about that, sorry. I deleted the commented code and now the test is not passing. Tomorrow will be trying the fix both of you suggested. Thank you for your response!