To explain why to use the window.
notation a little more (because I was confused at some point with it too) Webpack wraps your code in functions to create scope, so that each file can act as an independent module. This keeps your various modules from polluting the global scope or each other and also means test is not available to the browser console. If you just want to call your test function from the browser console try assigning test to the window
object.
There's a great answer at SO on options with several approaches for globals here https://stackoverflow.com/a/40416826/610880