I am currently faced with the challenge of running automated unit tests in the terminal for a library application that utilizes the History API internally. To achieve this, I am utilizing Babel to transpile and consolidate my Mocha/Chai/Sinon unit tests into a single test file. Subsequently, I load a local HTML file (which incorporates the test file) into Headless Chrome to execute the tests successfully.
However, my progress was hindered when Headless Chrome started throwing errors due to my utilization of the pushState
method of the History API on a local file. The specific error message reads as follows:
Error: Failed to execute 'pushState' on 'History': A history state object with URL 'file:///C:/code/projects/app/test/foo' cannot be created in a document with origin 'null' and URL 'file:///C:/code/projects/app/test/runner.html'.
To address this issue, I decided to implement gulp-connect in order to establish a local server that initiates at the start of the gulp task and shuts down upon completion, eliminating the need for a persistent connection. By reconfiguring everything to operate through the server, the previous error was resolved.
However, a new problem emerged where the terminal ceased to display the results of the unit tests. Despite Gulp notifying me that the task begins and concludes, no further information is provided. This gives the false impression that all tests are passing even when intentionally failing one.
Any insights on what might be causing this setback? I initially anticipated a smooth transition, but it seems like I may have overlooked something trivial (a common occurrence). If necessary, I am open to exploring other options such as migrating from Gulp to NPM scripts to rectify the issue. Ultimately, my goal is to establish an automated process that can be executed manually as well as by Travis CI upon each push to the public repository.