Skip to content
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

Added debug configuration for vscode #1

Merged
merged 11 commits into from
Nov 30, 2018
Merged
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "Debug tests",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"debug-tests"
],
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/build/**/*.js"
],
"protocol": "inspector",
"port": 9229
}
]
}
13 changes: 13 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"option": "watch",
"problemMatcher": [
"$tsc-watch"
]
}
]
}
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changes

### 0.3.1
- Refactored the test runner and test loader to reduce coupling
- Created debug config for vscode

### 0.3.0
- Added more info in README.md

### 0.2.0
- Fixed some grammar mistakes in the README.md
- Added this CHANGES.md file
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# TestyTs
[![Build Status](https://travis-ci.com/Aboisier/TestyTs.svg?token=vuBsBM3yD6PMvt3zwT9s&branch=master)](https://travis-ci.com/Aboisier/TestyTs)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.jparrowsec.cn%2FAboisier%2FTestyTs.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.jparrowsec.cn%2FAboisier%2FTestyTs?ref=badge_shield)

[![Build Status](https://travis-ci.org/Testy/TestyTs.svg?branch=master)](https://travis-ci.org/Testy/TestyTs)

TestyTs is a modern TypeScript testing framework.

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "testyts",
"version": "0.3.0",
"version": "0.3.1",
"icon": "img/test-icon-128x128.png",
"description": "Modern test framework for TypeScript.",
"main": "build/testyCore.js",
"bin": "build/testy.js",
"scripts": {
"test": "tsc & node build/testy.js & npm run lint",
"debug-tests": "node --nolazy --inspect-brk=9229 build/testy.js",
"build": "tsc",
"lint": "tslint -c tslint.json 'src/**/*.ts'",
"lint-fix": "tslint -c tslint.json 'src/**/*.ts' --fix"
Expand Down
25 changes: 14 additions & 11 deletions src/lib/cli/run.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,27 @@ import { TestsLoader } from '../utils/testsLoader';
import { CliCommand } from './cliCommand';

export class RunCommand implements CliCommand {
public get configFile(): string { return this._configFile; }
public get testyConfigFile(): string { return this._testyConfigFile; }
public get tsConfigFile(): string { return this._tsConfigFile; }

private readonly defaultConfig: TestyConfig = {
include: ['**/*.spec.ts']
};

constructor(private logger: Logger, private _configFile: string = 'testy.json') { }
constructor(private logger: Logger, private _testyConfigFile: string = 'testy.json', private _tsConfigFile = 'tsconfig.json') { }

public async execute() {
const configPath = resolve(process.cwd(), this._configFile);
if (!existsSync(configPath))
throw new Error(`The specified configuration file could not be found: ${configPath}`);
const testyConfigPath = resolve(process.cwd(), this._testyConfigFile);
const tsconfigPath = resolve(process.cwd(), this._tsConfigFile);

if (!existsSync(testyConfigPath))
throw new Error(`The specified Testy configuration file could not be found: ${testyConfigPath}`);

if (!existsSync(testyConfigPath))
throw new Error(`The specified tsconfig configuration file could not be found: ${testyConfigPath}`);


const testsLoader = new TestsLoader(this.logger);
const testRunner = new TestRunner(this.logger);

const config: TestyConfig = await import(configPath);
const tsconfig = require('../tsconfig.json');
const config: TestyConfig = await import(testyConfigPath);
const tsconfig = await import(tsconfigPath);
const testSuites = await testsLoader.loadTests(process.cwd(), config.include, tsconfig);
const report = await testRunner.runTests(testSuites);
report.printStatistics();
Expand Down
2 changes: 1 addition & 1 deletion src/spec/cli/cli.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class CliTests {
// Assert
expect.toBeTrue(command instanceof RunCommand);
const runCommand = command as RunCommand;
expect.toBeEqual(runCommand.configFile, expectedConfig);
expect.toBeEqual(runCommand.testyConfigFile, expectedConfig);
}

@test('testy init')
Expand Down