-
Notifications
You must be signed in to change notification settings - Fork 929
test: refactor test utils to typescript #906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
byCedric
merged 4 commits into
conventional-changelog:master
from
armano2:refactor-test-utils
Jan 26, 2020
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -10,4 +10,4 @@ package-lock.json | |
lib/ | ||
package.json.lerna_backup | ||
/*.iml | ||
tsconfig.tsbuildinfo | ||
tsconfig.tsbuildinfo |
This file contains hidden or 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,24 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Jest Test Current file", | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js", | ||
"cwd": "${workspaceFolder}", | ||
"args": [ | ||
"--runInBand", | ||
"--no-cache", | ||
"--no-coverage", | ||
"${fileBasename}" | ||
], | ||
"sourceMaps": true, | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen" | ||
} | ||
] | ||
} |
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,24 @@ | ||
import tmp from 'tmp'; | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
import pkgDir from 'pkg-dir'; | ||
|
||
async function bootstrap(fixture?: string): Promise<string> { | ||
const tmpDir = tmp.dirSync({ | ||
keep: false, | ||
unsafeCleanup: true | ||
}); | ||
|
||
if (typeof fixture !== 'undefined') { | ||
const packageDir = await pkgDir(); | ||
if (!packageDir) { | ||
throw new Error(`ENOENT, no such file or directory '${packageDir}'`); | ||
byCedric marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
await fs.copy(path.join(packageDir, fixture), tmpDir.name); | ||
} | ||
|
||
return tmpDir.name; | ||
} | ||
|
||
export {bootstrap}; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,34 @@ | ||
import execa from 'execa'; | ||
|
||
import * as fix from './fix'; | ||
|
||
export async function bootstrap(fixture?: string) { | ||
const cwd = await fix.bootstrap(fixture); | ||
|
||
await init(cwd); | ||
return cwd; | ||
} | ||
|
||
export async function clone(source: string, ...args: string[]) { | ||
const cwd = await fix.bootstrap(); | ||
|
||
await execa('git', ['clone', ...args, source, cwd]); | ||
await setup(cwd); | ||
return cwd; | ||
} | ||
|
||
export async function init(cwd: string) { | ||
await execa('git', ['init', cwd]); | ||
await setup(cwd); | ||
return cwd; | ||
} | ||
|
||
async function setup(cwd: string) { | ||
try { | ||
await execa('git', ['config', 'user.name', 'ava'], {cwd}); | ||
await execa('git', ['config', 'user.email', '[email protected]'], {cwd}); | ||
await execa('git', ['config', 'commit.gpgsign', 'false'], {cwd}); | ||
} catch (err) { | ||
console.warn(`git config in ${cwd} failed`, err.message); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,32 @@ | ||
import * as u from '.'; | ||
import os from 'os'; | ||
import path from 'path'; | ||
import fs from 'fs-extra'; | ||
|
||
test('exports a git namespace', () => { | ||
expect(typeof u.git).toBe('object'); | ||
}); | ||
|
||
test('git namespace has bootstrap', () => { | ||
expect(typeof u.git.bootstrap).toBe('function'); | ||
}); | ||
|
||
test('git namespace has clone', () => { | ||
expect(typeof u.git.clone).toBe('function'); | ||
}); | ||
|
||
test('expect to create tmp directory', async () => { | ||
const directory = await u.git.bootstrap(); | ||
expect(directory).toContain('tmp-'); | ||
expect(directory).toContain(os.tmpdir()); | ||
}); | ||
|
||
test('expect to create tmp from directory from src', async () => { | ||
const directory = await u.git.bootstrap('.github'); | ||
expect(directory).toContain('tmp-'); | ||
expect(directory).toContain(os.tmpdir()); | ||
expect(fs.existsSync(directory)).toBeTruthy(); | ||
|
||
const indexFile = path.join(directory, 'ISSUE_TEMPLATE.md'); | ||
expect(fs.existsSync(indexFile)).toBeTruthy(); | ||
}); |
File renamed without changes.
This file contains hidden or 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 hidden or 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,15 @@ | ||
{ | ||
"extends": "../../tsconfig.shared.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"rootDir": "./src", | ||
"outDir": "./lib" | ||
}, | ||
"include": [ | ||
"./src" | ||
], | ||
"exclude": [ | ||
"./src/**/*.test.ts", | ||
"./lib/**/*" | ||
] | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.