Skip to content

Commit 36a9f83

Browse files
authored
Merge pull request #190 from NativeScript/iiivanov/add-tests
Add tests and integrate Travis CI
2 parents 8690456 + deea160 commit 36a9f83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+497
-1591
lines changed

.travis.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: node_js
2+
3+
node_js:
4+
- "8.0"
5+
6+
script:
7+
- npm run build
8+
- npm test
9+
- npm run tslint

.vscode/launch.json

+19-58
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
"version": "0.1.0",
33
"configurations": [
44
{
5-
"name": "launch as server",
5+
"name": "Launch as server",
66
"type": "node",
77
"request": "launch",
88
"program": "${workspaceRoot}/out/debug-adapter/nativeScriptDebug.js",
9-
"runtimeArgs": ["--nolazy"],
9+
"runtimeArgs": ["--nolazy"],
1010
"args": [ "--server=4712" ],
1111
"stopOnEntry": false,
1212
"sourceMaps": true,
1313
"outFiles": [ "${workspaceFolder}/out/**/*.js" ],
1414
"cwd": "${workspaceFolder}"
1515
},
1616
{
17-
"name": "launch in extension host",
17+
"name": "Launch in extension host",
1818
"type": "extensionHost",
1919
"request": "launch",
2020
// Path to VSCode executablensDebugClient
@@ -24,61 +24,22 @@
2424
],
2525
"stopOnEntry": false,
2626
"sourceMaps": true,
27-
"outFiles": [ "${workspaceFolder}/out/**/*.js" ],
27+
"outFiles": [ "${workspaceFolder}/out/**/*.js" ]
2828
},
29-
{
30-
"name": "run tests on mac",
31-
"type": "node",
32-
"request": "launch",
33-
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
34-
"runtimeArgs": [ "--nolazy" ],
35-
"args": [
36-
"--opts", "${workspaceRoot}/src/tests/config/mocha.opts",
37-
"--config", "${workspaceRoot}/src/tests/config/mac.json",
38-
"${workspaceRoot}/out/tests/"
39-
],
40-
"stopOnEntry": false,
41-
"sourceMaps": true,
42-
"outDir": "${workspaceRoot}/out",
43-
"cwd": "${workspaceRoot}"
44-
},
45-
{
46-
"name": "run tests on win",
47-
"type": "node",
48-
"request": "launch",
49-
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
50-
"runtimeArgs": [ "--nolazy" ],
51-
"args": [
52-
"--opts", "${workspaceRoot}/src/tests/config/mocha.opts",
53-
"--config", "${workspaceRoot}/src/tests/config/win.json",
54-
"${workspaceRoot}/out/tests/"
55-
],
56-
"stopOnEntry": false,
57-
"sourceMaps": true,
58-
"outDir": "${workspaceRoot}/out",
59-
"cwd": "${workspaceRoot}"
60-
},
61-
{
62-
"name": "run tests (custom)",
63-
"type": "node",
64-
"request": "launch",
65-
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
66-
"runtimeArgs": [ "--nolazy" ],
67-
"args": [
68-
"--opts", "${workspaceRoot}/src/tests/config/mocha.opts",
69-
"--config", "${workspaceRoot}/src/tests/config/custom.json",
70-
"${workspaceRoot}/out/tests/"
71-
],
72-
"stopOnEntry": false,
73-
"sourceMaps": true,
74-
"outDir": "${workspaceRoot}/out",
75-
"cwd": "${workspaceRoot}"
76-
}
29+
{
30+
"name": "Run tests",
31+
"type": "node",
32+
"request": "launch",
33+
"runtimeExecutable": "npm",
34+
"runtimeArgs": [
35+
"run", "test", "--"
36+
]
37+
}
7738
],
78-
"compounds": [
79-
{
80-
"name": "Extension + Server",
81-
"configurations": [ "launch in extension host", "launch as server" ]
82-
}
83-
]
39+
"compounds": [
40+
{
41+
"name": "Extension + Server",
42+
"configurations": [ "Launch in extension host", "Launch as server" ]
43+
}
44+
]
8445
}

package.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434
},
3535
"devDependencies": {
3636
"@types/lodash": "^4.14.109",
37-
"@types/mocha": "2.2.41",
37+
"@types/mocha": "^5.2.1",
3838
"@types/node": "6.0.46",
39-
"mocha": "2.5.3",
39+
"mocha": "^5.2.0",
40+
"sinon": "^5.0.10",
4041
"tslint": "5.10.0",
4142
"tslint-eslint-rules": "^5.3.1",
4243
"typescript": "2.6.2",
4344
"vsce": "~1.36.0",
4445
"vscode": "~1.1.10",
45-
"vscode-debugadapter-testsupport": "1.26.0",
4646
"vscode-debugprotocol": "^1.28.0-pre.1"
4747
},
4848
"scripts": {
@@ -52,9 +52,7 @@
5252
"package": "vsce package",
5353
"full-build": "npm run clean && npm install && npm run build && npm run package",
5454
"launch-as-server": "node --nolazy ./out/debug-adapter/nativeScriptDebug.js --server=4712",
55-
"test-mac": "mocha --opts ./src/tests/config/mocha.opts --config ../../src/tests/config/mac.json ./out/tests",
56-
"test-win": "mocha --opts ./src/tests/config/mocha.opts --config ../../src/tests/config/win.json ./out/tests",
57-
"test-custom": "mocha --opts ./src/tests/config/mocha.opts --config ../../src/tests/config/custom.json ./out/tests",
55+
"test": "mocha --opts ./src/tests/config/mocha.opts",
5856
"tslint": "tslint -p ./src/tsconfig.json -c tslint.json"
5957
},
6058
"main": "./out/main",

src/debug-adapter/nativeScriptDebug.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import * as os from 'os';
22
import * as path from 'path';
33
import { chromeConnection, ChromeDebugSession } from 'vscode-chrome-debug-core';
4-
import { NativeScriptDebugAdapter } from './nativeScriptDebugAdapter';
4+
import { AndroidProject } from '../project/androidProject';
5+
import { IosProject } from '../project/iosProject';
6+
import { NativeScriptCli } from '../project/nativeScriptCli';
7+
import { nativeScriptDebugAdapterGenerator } from './nativeScriptDebugAdapter';
58
import { NativeScriptPathTransformer } from './nativeScriptPathTransformer';
69
import { NativeScriptTargetDiscovery } from './nativeScriptTargetDiscovery';
710

@@ -13,7 +16,7 @@ class NSAndroidConnection extends chromeConnection.ChromeConnection {
1316

1417
ChromeDebugSession.run(ChromeDebugSession.getSession(
1518
{
16-
adapter: NativeScriptDebugAdapter,
19+
adapter: nativeScriptDebugAdapterGenerator(IosProject, AndroidProject, NativeScriptCli),
1720
chromeConnection: NSAndroidConnection,
1821
extensionName: 'nativescript-extension',
1922
logFilePath: path.join(os.tmpdir(), 'nativescript-extension.txt'),

0 commit comments

Comments
 (0)