-
-
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
281 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,30 @@ | ||
/** | ||
* 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 path = require('path'); | ||
const runJest = require('../runJest'); | ||
const {cleanup} = require('../utils'); | ||
|
||
const DIR = path.join(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).toHaveLength(1); | ||
const setup = fs.readFileSync(path.join(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,37 @@ | ||
/** | ||
* 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 mkdirp = require('mkdirp'); | ||
const os = require('os'); | ||
const path = require('path'); | ||
const runJest = require('../runJest'); | ||
const {cleanup} = require('../utils'); | ||
|
||
const DIR = path.join(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).toHaveLength(1); | ||
const teardown = fs.readFileSync(path.join(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,20 @@ | ||
/** | ||
* 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 path = require('path'); | ||
const os = require('os'); | ||
|
||
const DIR = path.join(os.tmpdir(), '/jest'); | ||
|
||
test('should exist setup file', () => { | ||
const files = fs.readdirSync(DIR); | ||
expect(files).toHaveLength(1); | ||
const setup = fs.readFileSync(path.join(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,20 @@ | ||
/** | ||
* 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 path = require('path'); | ||
const os = require('os'); | ||
|
||
const DIR = path.join(os.tmpdir(), '/jest'); | ||
|
||
test('should exist setup file', () => { | ||
const files = fs.readdirSync(DIR); | ||
expect(files).toHaveLength(1); | ||
const setup = fs.readFileSync(path.join(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,20 @@ | ||
/** | ||
* 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 path = require('path'); | ||
const os = require('os'); | ||
|
||
const DIR = path.join(os.tmpdir(), '/jest'); | ||
|
||
test('should exist setup file', () => { | ||
const files = fs.readdirSync(DIR); | ||
expect(files).toHaveLength(1); | ||
const setup = fs.readFileSync(path.join(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,22 @@ | ||
/** | ||
* 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 crypto = require('crypto'); | ||
const fs = require('fs'); | ||
const mkdirp = require('mkdirp'); | ||
const os = require('os'); | ||
const path = require('path'); | ||
|
||
const DIR = path.join(os.tmpdir(), '/jest'); | ||
|
||
module.exports = function() { | ||
return new Promise((resolve, reject) => { | ||
mkdirp.sync(DIR); | ||
const fileId = crypto.randomBytes(20).toString('hex'); | ||
fs.writeFileSync(path.join(DIR, '/', fileId), 'setup'); | ||
resolve(); | ||
}); | ||
}; |
18 changes: 18 additions & 0 deletions
18
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,18 @@ | ||
/** | ||
* 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 path = require('path'); | ||
const os = require('os'); | ||
|
||
const DIR = path.join(os.tmpdir(), '/jest'); | ||
|
||
test('should not exist teardown file', () => { | ||
const files = fs.readdirSync(DIR); | ||
expect(files).toHaveLength(0); | ||
}); |
18 changes: 18 additions & 0 deletions
18
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,18 @@ | ||
/** | ||
* 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 path = require('path'); | ||
const os = require('os'); | ||
|
||
const DIR = path.join(os.tmpdir(), '/jest'); | ||
|
||
test('should not exist teardown file', () => { | ||
const files = fs.readdirSync(DIR); | ||
expect(files).toHaveLength(0); | ||
}); |
18 changes: 18 additions & 0 deletions
18
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,18 @@ | ||
/** | ||
* 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 path = require('path'); | ||
const os = require('os'); | ||
|
||
const DIR = path.join(os.tmpdir(), '/jest'); | ||
|
||
test('should not exist teardown file', () => { | ||
const files = fs.readdirSync(DIR); | ||
expect(files).toHaveLength(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,22 @@ | ||
/** | ||
* 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 crypto = require('crypto'); | ||
const fs = require('fs'); | ||
const mkdirp = require('mkdirp'); | ||
const os = require('os'); | ||
const path = require('path'); | ||
|
||
const DIR = path.join(os.tmpdir(), '/jest'); | ||
|
||
module.exports = function() { | ||
return new Promise((resolve, reject) => { | ||
mkdirp.sync(DIR); | ||
const fileId = crypto.randomBytes(20).toString('hex'); | ||
fs.writeFileSync(path.join(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