Cannot test Mailspring locally-

I have some experience in Electron development and wanted to contribute to Mailspring, but I cannot run the tests locally.

I have run npm install and even npm run build, but when I use npm test, I get the following error in the browser console:

Error: Could not find a file at path '../../static/jasmine'
    at ThemeManager.requireStylesheet (/home/flotwig/src/Mailspring/app/src/theme-manager.ts:163)
    at SpecRunner._setupAppEnv (/home/flotwig/src/Mailspring/app/spec/spec-runner/spec-runner.ts:118)
    at SpecRunner.runSpecs (/home/flotwig/src/Mailspring/app/spec/spec-runner/spec-runner.ts:30)
    at Object.<anonymous> (/home/flotwig/src/Mailspring/app/spec/spec-runner/spec-bootstrap.ts:15)
    at Object.<anonymous> (/home/flotwig/src/Mailspring/app/spec/spec-runner/spec-bootstrap.ts:15)
    at Module._compile (/home/flotwig/src/Mailspring/app/static/internal/modules/cjs/loader.js:968)
    at Object.value [as .ts] (/home/flotwig/src/Mailspring/app/src/compile-cache.js:145)
    at Module.load (/home/flotwig/src/Mailspring/app/static/internal/modules/cjs/loader.js:816)
    at Module._load (/home/flotwig/src/Mailspring/app/static/internal/modules/cjs/loader.js:728)
    at Function.Module._load (/home/flotwig/src/Mailspring/app/static/electron/js2c/asar.js:748)
    at Module.require (/home/flotwig/src/Mailspring/app/static/internal/modules/cjs/loader.js:853)
    at require (/home/flotwig/src/Mailspring/app/static/internal/modules/cjs/helpers.js:74)
    at setupWindow (index.js:47)
    at window.onload (index.js:75)

…and a blank BrowserWindow is opened:

I am able to run the app locally and manually test via npm start but obviously I will need to run automated tests at some point.

Also, why doesn’t the included CircleCI config run these tests? It only lints the code.


I will try to have a look. However I am quite busy right now because of moving to a new house, so I am not sure how fast I will manage.

Any new contribution is highly welcome. :slight_smile:

1 Like

Thanks @Phylu. I got past this error by changing this line:

to AppEnv.themes.requireStylesheet(`${__dirname}/../../static/style/jasmine`);.

Now, it doesn’t error, but the tests go in the background and Electron just appears over and over and over again, for like a second each time:

This continues til I killall electron, with no progress.

Are these tests supposed to run? I did notice that they do not run in CI. Do they run on your system? I notice the contributing docs also don’t mention tests.

Just wanna get an idea of what’s supposed to work before I go breaking things :smiley: Thanks.

I am not really sure about that. Feel free to check out some of the open issues and focus on the tests later, if they are not working right now. :wink:

Thanks for the response. I find it really hard to make meaningful changes without tests, I hate doing lots of manual, error-prone QA after every change. I think that this project would be a lot more attractive to more new contributors if the test suite was documented and functioning. With the goal being to make Mailspring a truly community-based open source project, proper developer experience is essential. Plus, besides just developer experience, software quality really benefits from automated testing…

I did manage to get the tests running locally by preventDefaulting the beforeunload event in spec-runner:

Surprisingly, only about 40 out of 879 tests were failing, even though the test suite looked abandoned, so I’m going to work on finishing fixing those up. I have about 6 left.

Once I can get all the tests passing and running I will put my PR in “ready for review” and hopefully the next step can be to get the CI back up and running, which will ease some manual testing burden off of PR reviewers and PR authors alike.

And then my next PRs will be well-tested :slight_smile: