Skip to content

Conversation

@cwillisf
Copy link
Contributor

@cwillisf cwillisf commented Sep 19, 2017

Resolves

Jest-based integration tests currently do not run on Windows hosts.

Note that the integration tests don't run from Ubuntu-on-Windows without significant extra configuration. This change makes the tests work from a CMD prompt and maybe Cygwin.

Proposed Changes

This PR includes a few different changes which, combined, allow the tests to run on Windows. scratchfoundation/scratch-storage#22 should be treated as a prerequisite.

Reason for Changes

See the description of each commit below for a more thorough explanation. The short version:

  • Using [\\\\/] in the Jest test path arguments seems to be the only way to get the path to behave the same on both Windows and non-Windows platforms.
  • Without import 'chromedriver';, Jest / Selenium can't find chromedriver.exe on Windows. This might also help other platforms...?
  • Building as part of the integration test script makes iterating on the integration tests take a long time. However, it's important to build before running the integration tests. I've moved npm run build out of the integration test script and into the overall test script. In addition, I've changed the names of the test scripts as suggested by @rschamp.

/cc @fsih

Christopher Willis-Ford added 2 commits September 19, 2017 23:53
Jest takes an argument to specify which tests should be run. The
argument is treated as a regular expression and matched against the
filenames of potential tests. Unfortunately Jest does not normalize path
separators to forward slashes when running this comparison, so (for
example) `tests/unit` doesn't match anything on Windows.

This change replaces the forward slash in Jest arguments with `[\\\\/]`.

Ideally, that should just be `[\\/]` -- escaping the backslash so that
it survives NPM's JSON parsing -- but unfortunately the Windows version
of Jest parses its command line arguments differently from other
platforms. Specifically, the Windows version of Jest processes
backslashes one extra time. Fortunately having a redundant backslash is
OK on Mac and Linux, so `[\\\\/]` ends up working on all platforms.
Adding `import 'chromedriver';` causes the module to register the path
to `chromedriver` / `chromedriver.exe` automatically, fixing this error:
```
The ChromeDriver could not be found on the current PATH. Please download the latest version of the ChromeDriver from http://chromedriver.storage.googleapis.com/index.html and ensure it can be found on your PATH.
        at Error (native)
```
@cwillisf cwillisf self-assigned this Sep 19, 2017
@thisandagain
Copy link
Contributor

Related to:
#726
#727

Copy link
Contributor

@rschamp rschamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those paths are hilariously weird, but LGTM. If it works it works. Thanks for grouping the steps under test:.

@cwillisf cwillisf force-pushed the fix-tests-on-windows branch from 7d87f12 to c99f187 Compare October 11, 2017 16:49
@cwillisf cwillisf merged commit 59f2697 into scratchfoundation:develop Oct 11, 2017
@cwillisf cwillisf deleted the fix-tests-on-windows branch October 11, 2017 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants