-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const os = require('os'); | ||
const runJest = require('../runJest'); | ||
const {cleanup} = require('../utils'); | ||
|
||
const DIR = os.tmpdir() + '/jest'; | ||
|
||
beforeEach(() => cleanup(DIR)); | ||
afterAll(() => cleanup(DIR)); | ||
|
||
test('globalSetup is triggered once before all test suites', () => { | ||
const path = require('path'); | ||
const setupPath = path.resolve(__dirname, '../global_setup/setup.js'); | ||
const result = runJest.json('global_setup', [`--globalSetup=${setupPath}`]); | ||
expect(result.status).toBe(0); | ||
const files = fs.readdirSync(DIR); | ||
expect(files.length).toBe(1); | ||
const setup = fs.readFileSync(DIR + '/' + files[0], 'utf8'); | ||
expect(setup).toBe('setup'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const os = require('os'); | ||
const runJest = require('../runJest'); | ||
const {cleanup} = require('../utils'); | ||
const mkdirp = require('mkdirp'); | ||
|
||
const DIR = os.tmpdir() + '/jest'; | ||
|
||
beforeEach(() => cleanup(DIR)); | ||
afterAll(() => cleanup(DIR)); | ||
|
||
test('globalTeardown is triggered once after all test suites', () => { | ||
mkdirp.sync(DIR); | ||
const path = require('path'); | ||
const teardownPath = path.resolve( | ||
__dirname, | ||
'../global_teardown/teardown.js', | ||
); | ||
const result = runJest.json('global_teardown', [ | ||
`--globalTeardown=${teardownPath}`, | ||
]); | ||
expect(result.status).toBe(0); | ||
const files = fs.readdirSync(DIR); | ||
expect(files.length).toBe(1); | ||
const teardown = fs.readFileSync(DIR + '/' + files[0], 'utf8'); | ||
expect(teardown).toBe('teardown'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const os = require('os'); | ||
|
||
const DIR = os.tmpdir() + '/jest'; | ||
|
||
test('should exist setup file', () => { | ||
const files = fs.readdirSync(DIR); | ||
expect(files.length).toBe(1); | ||
const setup = fs.readFileSync(DIR + '/' + files[0], 'utf8'); | ||
expect(setup).toBe('setup'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const os = require('os'); | ||
|
||
const DIR = os.tmpdir() + '/jest'; | ||
|
||
test('should exist setup file', () => { | ||
const files = fs.readdirSync(DIR); | ||
expect(files.length).toBe(1); | ||
const setup = fs.readFileSync(DIR + '/' + files[0], 'utf8'); | ||
expect(setup).toBe('setup'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const os = require('os'); | ||
|
||
const DIR = os.tmpdir() + '/jest'; | ||
|
||
test('should exist setup file', () => { | ||
const files = fs.readdirSync(DIR); | ||
expect(files.length).toBe(1); | ||
const setup = fs.readFileSync(DIR + '/' + files[0], 'utf8'); | ||
expect(setup).toBe('setup'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
const fs = require('fs'); | ||
const crypto = require('crypto'); | ||
const os = require('os'); | ||
const mkdirp = require('mkdirp'); | ||
|
||
const DIR = os.tmpdir() + '/jest'; | ||
|
||
module.exports = function() { | ||
return new Promise((resolve, reject) => { | ||
mkdirp.sync(DIR); | ||
const fileId = crypto.randomBytes(20).toString('hex'); | ||
fs.writeFileSync(DIR + '/' + fileId, 'setup'); | ||
resolve(); | ||
}); | ||
}; |
17 changes: 17 additions & 0 deletions
17
integration_tests/global_teardown/__tests__/teardown1.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const os = require('os'); | ||
|
||
const DIR = os.tmpdir() + '/jest'; | ||
|
||
test('should not exist teardown file', () => { | ||
const files = fs.readdirSync(DIR); | ||
expect(files.length).toBe(0); | ||
}); |
17 changes: 17 additions & 0 deletions
17
integration_tests/global_teardown/__tests__/teardown2.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const os = require('os'); | ||
|
||
const DIR = os.tmpdir() + '/jest'; | ||
|
||
test('should not exist teardown file', () => { | ||
const files = fs.readdirSync(DIR); | ||
expect(files.length).toBe(0); | ||
}); |
17 changes: 17 additions & 0 deletions
17
integration_tests/global_teardown/__tests__/teardown3.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const os = require('os'); | ||
|
||
const DIR = os.tmpdir() + '/jest'; | ||
|
||
test('should not exist teardown file', () => { | ||
const files = fs.readdirSync(DIR); | ||
expect(files.length).toBe(0); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
const fs = require('fs'); | ||
const crypto = require('crypto'); | ||
const os = require('os'); | ||
const mkdirp = require('mkdirp'); | ||
|
||
const DIR = os.tmpdir() + '/jest'; | ||
|
||
module.exports = function() { | ||
return new Promise((resolve, reject) => { | ||
mkdirp.sync(DIR); | ||
const fileId = crypto.randomBytes(20).toString('hex'); | ||
fs.writeFileSync(DIR + '/' + fileId, 'teardown'); | ||
resolve(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters