URL Shortener Microservice needs tests
See original GitHub issueI’m creating this as a place to discuss how to create tests for this project, so as not to dominate #37185
@ojeytonwilliams For URL Shortener, I need to POST URL (google for example) to shorten it and it should return
{ "original_url": "www.google.com", "short_url": 1 }
. When I access$.get(getUserInput(''url'') + ''/api/shorturl/1'')
, I should be redirected to google.com.I will need to either 1) store the original_url as a variable OR 2) POST and then GET in one function. Is there a way to do the first one because that would be cleaner and more readable? And where does the first getUserInput get called from actually?
Here’s an excerpt of my test, second test incomplete:
tests: - text: 'It should handle a URL as parameter and return shortened URL' testString: 'getUserInput => $.post(getUserInput('url') + '/api/shorturl/new').then(data => assert.exists(data.short_url), xhr => { throw new Error(xhr.responseText)})' - text: 'It should handle a shortened URL and redirect to original link' testString: 'getUserInput => $.get(getUserInput(''url'') + ''/api/shorturl/3'').then()
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (12 by maintainers)
Top Results From Across the Web
URL Shortener Microservice - Why my project is not passing ...
Hello. Can anyone help me to understand why my project is not passing the tests? My project is failing two of the tests...
Read more >FreeCodeCamp-APIs and Microservices — URL Shortener ...
We have a pending connection to the test database running on localhost. We now need to get notified if we connect successfully or...
Read more >FreeCodeCamp: URL Shortener Microservice - YouTube
... https://www.freecodecamp.org/learn/back-end-development-and-apis/back-end-development-and-apis-projects/ url - shortener - microservice.
Read more >URL Shortener Microservice - freeCodeCamp APIs ... - YouTube
This is a full walkthrough for the URL Shortener Microservice project on freeCodeCamp. After setting up a database connection we create a ...
Read more >URL Shortener Microservice | FreeCodeCamp - YouTube
I build the URL Shortener Microservice on FreeCodeCamp. This project was quite a bit tougher than the ones before it.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for testing that. So, what I think is that the
window
object should be off-limits as the potential for creating bizarre and unpredictable bugs is rather high.Right now we run the tests sequentially, but what about if we decide to run them in parallel to speed things up? After all, waiting for multiple 5 second timeouts is a pain. Suddenly these kinds of tests can fail, more or less at random. Even if we keep the test-runner synced, it makes it hard to maintain as you can’t simply change one test - you might have to change all the dependent tests.
So, while we can do this, I think we’d regret it.
I put a link on the main issue to some examples, or possibly stuff that can just be copy/pasted - looks like whoever made them stores some variables on the window object.