A way of testing javascript/typescript in browser after bundling

283 Views Asked by At

I'm writing a web app with my friend. He writes the Fronted, I write the Backend. Problem is that there is no way of me testing my code if my friend haven't wrote the integration yet, because we bundle the code in web pack and run it on a dev server. My question is, is there a way that I could test my typescript code (call functions with parameters) in chrome console, like I could test unbundled javascript?

1

There are 1 best solutions below

0
JSmart523 On

The professional answer is: Don't do that!

  • Test the actual server using Postman.
  • Write unit tests for your api-handling client code that intercepts calls to the server (because those aren't unit tests), via jest or some other unit testing library.
  • Write unit tests for the front end that doesn't actually touch your middle-code.
  • Convert unit tests to assertions where you can, because case coverage beats code coverage and you can't possible think of everything during unit tests.
  • Write integration tests that are user-centric, not widget centric.

And that's hard but you'll be glad you did it... if you can do it without the project dying because of it! For a project that is just you and a friend, that may be a mighty big "if"!

So the realistic answer is probably: Write... or get your friend to write... an ugly-but-functional page you can use to enter some values and click a button to submit it, and then add debugger as a statement near the start of the button code. debugger is a hardcode breakpoint that dev tools will pause at.

Once that's written and working you should be able to modify it as needed. ...just remember not to let that page escape into production.