# Cannot test Mailspring locally-

**URL:** <https://community.getmailspring.com/t/cannot-test-mailspring-locally/2629>\
**Category:** Development\
**Created:** [August 26, 2021, 5:10pm UTC](https://community.getmailspring.com/t/cannot-test-mailspring-locally/2629 "2021-08-26T17:10:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![flotwig](https://community.getmailspring.com/user_avatar/community.getmailspring.com/flotwig/32/3054_2.png) [@flotwig](https://community.getmailspring.com/u/flotwig)\
**Post date:** [August 26, 2021, 5:10pm UTC](https://community.getmailspring.com/t/cannot-test-mailspring-locally/2629/1 "2021-08-26T17:10:30Z")

</div>

Hello,  
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:

```auto
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:

 ![image](https://community.getmailspring.com/uploads/default/original/2X/c/cbf4b991772c2ca8fd7a1fcbba0f816a9db9bbaf.png)

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.

Thanks,  
Zach

---

<div class="post-metadata">

**Author:** ![Phylu](https://community.getmailspring.com/user_avatar/community.getmailspring.com/phylu/32/35_2.png) [@Phylu](https://community.getmailspring.com/u/Phylu)\
**Post date:** [August 26, 2021, 7:54pm UTC](https://community.getmailspring.com/t/cannot-test-mailspring-locally/2629/2 "2021-08-26T19:54:46Z")

</div>

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. 🙂

---

<div class="post-metadata">

**Author:** ![flotwig](https://community.getmailspring.com/user_avatar/community.getmailspring.com/flotwig/32/3054_2.png) [@flotwig](https://community.getmailspring.com/u/flotwig)\
**Post date:** [August 26, 2021, 10:18pm UTC](https://community.getmailspring.com/t/cannot-test-mailspring-locally/2629/3 "2021-08-26T22:18:41Z")

</div>

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

> <https://github.com/flotwig/Mailspring/blob/44853d81e70aac13de7de4d35708c4efebfded35/app/spec/spec-runner/spec-runner.ts#L118-L118>

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:

 ![image](https://community.getmailspring.com/uploads/default/original/2X/6/6b5ac8d72e5ebb26ba62ff0aaae8abaaf034d66b.png)

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 😃 Thanks.

---

<div class="post-metadata">

**Author:** ![Phylu](https://community.getmailspring.com/user_avatar/community.getmailspring.com/phylu/32/35_2.png) [@Phylu](https://community.getmailspring.com/u/Phylu)\
**Post date:** [August 27, 2021, 5:04am UTC](https://community.getmailspring.com/t/cannot-test-mailspring-locally/2629/4 "2021-08-27T05:04:33Z")

</div>

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. 😉

---

<div class="post-metadata">

**Author:** ![flotwig](https://community.getmailspring.com/user_avatar/community.getmailspring.com/flotwig/32/3054_2.png) [@flotwig](https://community.getmailspring.com/u/flotwig)\
**Post date:** [August 27, 2021, 6:17am UTC](https://community.getmailspring.com/t/cannot-test-mailspring-locally/2629/5 "2021-08-27T06:17:12Z")

</div>

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](https://community.getmailspring.com/t/a-free-open-source-future-for-mailspring/484), 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 `preventDefault`ing the `beforeunload` event in `spec-runner`:

> <https://github.com/flotwig/Mailspring/blob/625648c9bea69f877b500b2ff0645ac6358549e7/app/spec/spec-runner/spec-runner.ts#L123-L125>

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](https://github.com/Foundry376/Mailspring/pull/2341) 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 🙂
