Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Commit

Permalink
chore(tests): Migrate to jest
Browse files Browse the repository at this point in the history
  • Loading branch information
Morten Henriksen committed Feb 11, 2018
1 parent 12e03a9 commit 6f28c0f
Show file tree
Hide file tree
Showing 6 changed files with 1,573 additions and 216 deletions.
57 changes: 36 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,45 @@
"vscode-debugprotocol": "1.19.0"
},
"devDependencies": {
"concurrently": "3.4.0",
"@types/es6-promise": "0.0.32",
"@types/mocha": "2.2.45",
"@types/jest": "^22.1.2",
"@types/node": "7.0.43",
"mocha": "3.2.0",
"concurrently": "3.4.0",
"jest": "^22.2.2",
"semantic-release": "10.0.1",
"semantic-release-vsce": "0.1.4",
"ts-jest": "^22.0.3",
"tslint": "5.8.0",
"typescript": "2.7.1",
"vscode": "1.1.10",
"vscode-debugadapter-testsupport": "1.19.0",
"tslint": "5.8.0"
"vscode-debugadapter-testsupport": "1.19.0"
},
"scripts": {
"prepublish": "tsc -p ./src",
"compile": "tsc -p ./src",
"tslint": "tslint ./src/**/*.ts",
"watch": "tsc -w -p ./src",
"test": "tsc -p ./src && mocha -u tdd ./out/tests/",
"test": "ts-jest",
"test:w": "concurrently \"tsc -p ./src\" \"mocha -u tdd ./out/tests/ --watch\"",
"postinstall": "node ./node_modules/vscode/bin/install",
"test2": "cd src/tests && electron-mocha ./test.js",
"publish:vsce": "./publish_vsce.sh",
"semantic-release": "semantic-release"
},
"jest": {
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "/src/tests/.*.test.ts$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
},
"main": "./out/extension",
"activationEvents": [
"onCommand:extension.perl-debug.provideInitialConfigurations"
Expand All @@ -89,8 +104,8 @@
"program": "./out/perlDebug.js",
"runtime": "node",
"languages": [
"perl"
],
"perl"
],
"configurationAttributes": {
"launch": {
"required": [
Expand Down Expand Up @@ -151,12 +166,12 @@
}
}
},
"initialConfigurations": [
{
"type": "perl",
"request": "launch",
"name": "Perl-Debug local",
"program": "${workspaceFolder}/${relativeFile}",
"initialConfigurations": [
{
"type": "perl",
"request": "launch",
"name": "Perl-Debug local",
"program": "${workspaceFolder}/${relativeFile}",
"exec": "perl",
"execArgs": [],
"root": "${workspaceRoot}/",
Expand All @@ -165,16 +180,16 @@
"env": {},
"stopOnEntry": true
},
{
"type": "perl",
"request": "launch",
"name": "Perl-Debug remote",
"program": "${workspaceFolder}/${relativeFile}",
{
"type": "perl",
"request": "launch",
"name": "Perl-Debug remote",
"program": "${workspaceFolder}/${relativeFile}",
"root": "${workspaceRoot}/",
"stopOnEntry": true,
"port": 5000
}
]
}
]
}
]
}
Expand Down
28 changes: 14 additions & 14 deletions src/tests/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {DebugClient} from 'vscode-debugadapter-testsupport';
import {DebugProtocol} from 'vscode-debugprotocol';


suite('Perl debug Adapter', () => {
describe('Perl debug Adapter', () => {

const DEBUG_ADAPTER = './out/perlDebug.js';

Expand Down Expand Up @@ -62,19 +62,19 @@ suite('Perl debug Adapter', () => {

let dc: DebugClient;

setup( () => {
beforeEach( () => {
dc = new DebugClient('node', DEBUG_ADAPTER, 'perl');
return dc.start();
});

teardown(() => {
afterEach(() => {
dc.stop();
printLogFile();
});

suite('basic', () => {
describe('basic', () => {

test('unknown request should produce error', done => {
it('unknown request should produce error', done => {
dc.send('illegal_request').then(() => {
done(new Error("does not report error on unknown request"));
}).catch(() => {
Expand All @@ -83,15 +83,15 @@ suite('Perl debug Adapter', () => {
});
});

suite('initialize', () => {
describe('initialize', () => {

test('should return supported features', () => {
it('should return supported features', () => {
return dc.initializeRequest().then(response => {
assert.equal(response.body.supportsConfigurationDoneRequest, true);
});
});

test('should produce error for invalid \'pathFormat\'', done => {
it('should produce error for invalid \'pathFormat\'', done => {
dc.initializeRequest({
adapterID: 'mock',
linesStartAt1: true,
Expand All @@ -106,9 +106,9 @@ suite('Perl debug Adapter', () => {
});
});

suite('launch', () => {
describe('launch', () => {

test('should run program to the end', async () => {
it('should run program to the end', async () => {
const PROGRAM = Path.join(DATA_ROOT, FILE_FAST_TEST_PL);

assert.ok(fs.existsSync(PROGRAM), `Test program "${PROGRAM}" not found`);
Expand All @@ -132,9 +132,9 @@ suite('Perl debug Adapter', () => {

// xxx: Need to figure out this test
// hint: It might be a missing "stop" event - is the application run?
suite.skip('setBreakpoints', () => {
describe.skip('setBreakpoints', () => {

test('should stop on a breakpoint', async () => {
it('should stop on a breakpoint', async () => {
const PROGRAM = Path.join(DATA_ROOT, FILE_FAST_TEST_PL);
const BREAKPOINT_LINE = 9;

Expand All @@ -160,9 +160,9 @@ suite('Perl debug Adapter', () => {
});

// TODO: Need to be able to replicate this
suite.skip('setExceptionBreakpoints', () => {
describe.skip('setExceptionBreakpoints', () => {

test('should stop on an exception', () => {
it('should stop on an exception', () => {

const PROGRAM_WITH_EXCEPTION = Path.join(DATA_ROOT, FILE_BROKEN_CODE);
const EXCEPTION_LINE = 10;
Expand Down
Loading

0 comments on commit 6f28c0f

Please sign in to comment.