Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1de02e

Browse files
committed
working test runner
1 parente61fdae commita1de02e

File tree

2 files changed

+23
-27
lines changed

2 files changed

+23
-27
lines changed

‎src/editor/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const createCommands = ({ extensionPath, workspaceState, workspaceRoot }:
6161
},
6262
onFail:(payload:Payload,message:string)=>{
6363
// send test fail message back to client
64-
vscode.window.showWarningMessage(`FAIL:${message}`)
64+
vscode.window.showWarningMessage(`FAIL${message}`)
6565
webview.send({type:'TEST_FAIL', payload})
6666
},
6767
onError:(payload:Payload)=>{

‎src/services/testRunner/index.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
importnodefrom'../../services/node'
22
import{getOutputChannel}from'../../editor/outputChannel'
33
importparserfrom'./parser'
4-
import{setLatestProcess,isLatestProcess}from'./throttle'
4+
//import { setLatestProcess, isLatestProcess } from './throttle'
55

66
exportinterfacePayload{
77
stepId:string
@@ -22,50 +22,46 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {
2222
constoutputChannelName='TEST_OUTPUT'
2323

2424
returnasync(payload:Payload,onSuccess?:()=>void):Promise<void>=>{
25-
console.log('-------------------run test------------------')
25+
console.log('-------------------RUN TEST -------------------')
2626

2727
// flag as running
2828
callbacks.onRun(payload)
2929

3030
letresult:{stdout:string|undefined;stderr:string|undefined}
3131
try{
32-
result=awaitnode.exec(config.command)
32+
result=awaitnode.exec('npm test')
3333
}catch(err){
34-
result=err
34+
console.log(err)
35+
result={stdout:err.stdout,stderr:err.stack}
3536
}
3637
const{ stdout, stderr}=result
3738

38-
// simple way to throttle requests
39-
if(!stdout){
40-
return
41-
}
42-
39+
consttap=parser(stdout||'')
4340
if(stderr){
44-
callbacks.onError(payload)
45-
46-
// open terminal with error string
47-
constchannel=getOutputChannel(outputChannelName)
48-
channel.show(false)
49-
channel.appendLine(stderr)
50-
return
41+
// failures also trigger stderr
42+
if(stdout&&stdout.length&&!tap.ok){
43+
constmessage=tap.message ?tap.message :''
44+
callbacks.onFail(payload,message)
45+
return
46+
}else{
47+
callbacks.onError(payload)
48+
// open terminal with error string
49+
constchannel=getOutputChannel(outputChannelName)
50+
channel.show(false)
51+
channel.appendLine(stderr)
52+
return
53+
}
5154
}
5255

53-
// pass or fail?
54-
consttap=parser(stdout)
56+
// success!
5557
if(tap.ok){
5658
callbacks.onSuccess(payload)
5759
if(onSuccess){
5860
onSuccess()
5961
}
6062
}else{
61-
// TODO: consider logging output to channel
62-
// open terminal with failed test string
63-
// const channel = getOutputChannel(outputChannelName)
64-
// channel.show(false)
65-
// channel.appendLine(tap.message)
66-
67-
constmessage=tap.message ?tap.message :''
68-
callbacks.onFail(payload,message)
63+
// should never get here
64+
callbacks.onError(payload)
6965
}
7066
}
7167
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp