Make sure __DARWIN__ and __WIN32__ are defined for tests

This commit is contained in:
joshaber 2016-10-03 17:25:59 -04:00
parent bbad299ce0
commit bec9a0b7e0
3 changed files with 6 additions and 7 deletions

View file

@ -10,12 +10,6 @@ import { Dispatcher, AppStore, GitHubUserStore, CloningRepositoriesStore, EmojiS
import { InMemoryDispatcher } from './in-memory-dispatcher'
import { TestDatabase } from './test-github-user-database'
// These constants are defined by Webpack at build time, but since tests aren't
// built with Webpack we need to make sure these exist at runtime.
const g: any = global
g['__WIN32__'] = process.platform === 'win32'
g['__DARWIN__'] = process.platform === 'darwin'
describe('App', () => {
let appStore: AppStore | null = null
let dispatcher: Dispatcher | null = null

5
app/test/globals.ts Normal file
View file

@ -0,0 +1,5 @@
// These constants are defined by Webpack at build time, but since tests aren't
// built with Webpack we need to make sure these exist at runtime.
const g: any = global
g['__WIN32__'] = process.platform === 'win32'
g['__DARWIN__'] = process.platform === 'darwin'

View file

@ -6,7 +6,7 @@
"description": "The People's Glorious GitHub Client's build dependencies",
"scripts": {
"test:integration": "cross-env TEST_ENV=1 ELECTRON_NO_ATTACH_CONSOLE=1 mocha -t 10000 --require ts-node/register app/test/integration/*.ts",
"test:unit": "cross-env TEST_ENV=1 ELECTRON_NO_ATTACH_CONSOLE=1 electron-mocha --renderer --require ts-node/register app/test/*.ts app/test/*.tsx",
"test:unit": "cross-env TEST_ENV=1 ELECTRON_NO_ATTACH_CONSOLE=1 electron-mocha --renderer --require ts-node/register --require ./app/test/globals.ts app/test/*.ts app/test/*.tsx",
"test": "npm run test:unit && npm run test:integration",
"postinstall": "cd app && npm install && cd .. && git submodule update --recursive --init",
"start": "node script/start",