-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: colocate test fixtures within the repo (#4)
- Loading branch information
Showing
6 changed files
with
345 additions
and
26 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
Binary file not shown.
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 |
---|---|---|
@@ -1,25 +1,33 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const os = require('os') | ||
const childProcess = require('child_process') | ||
const rimraf = require('rimraf') | ||
const { testProject } = require('../src') | ||
|
||
let tmpDir | ||
const decompress = require('decompress') | ||
|
||
beforeAll(() => { | ||
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'snync-')) | ||
childProcess.spawnSync('git', ['clone', '[email protected]:snyk-labs/snync-fixtures.git'], { | ||
cwd: tmpDir | ||
}) | ||
}) | ||
const projectFixtures = ['simple-project.zip'] | ||
|
||
const destinationFixtures = path.resolve(path.join(__dirname, '__fixtures__', 'tmp')) | ||
|
||
afterAll(() => { | ||
rimraf.sync(tmpDir) | ||
beforeAll(async () => { | ||
if (!fs.existsSync(destinationFixtures)) { | ||
fs.mkdirSync(destinationFixtures) | ||
} | ||
|
||
for (const fixtureName of projectFixtures) { | ||
const fixtureProjectPath = path.resolve(path.join(__dirname, '__fixtures__', fixtureName)) | ||
const fixtureDirectoryName = path.basename(fixtureName, '.zip') | ||
if (fs.existsSync(path.resolve(path.join(destinationFixtures, fixtureDirectoryName)))) { | ||
continue | ||
} else { | ||
await decompress(fixtureProjectPath, destinationFixtures) | ||
} | ||
} | ||
}) | ||
|
||
test('integration test', async () => { | ||
const projectPath = path.resolve(path.join(destinationFixtures, 'simple-project')) | ||
|
||
let out = '' | ||
await testProject(`${tmpDir}/snync-fixtures`, (...args) => (out += `${args.join(' ')}\n`)) | ||
await testProject(projectPath, (...args) => (out += `${args.join(' ')}\n`)) | ||
expect(out).toMatchSnapshot() | ||
}) |
Oops, something went wrong.