Skip to content

Commit 035b312

Browse files
Copilotkobenguyent
andcommitted
Changes before error encountered
Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
1 parent 6d10aa5 commit 035b312

25 files changed

+82
-76
lines changed

lib/mocha/asyncWrapper.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function makeDoneCallableOnce(done) {
4848
export function test(testInstance) {
4949
const testFn = testInstance.fn
5050
if (!testFn) {
51-
return testInstanceInstance
51+
return testInstance
5252
}
5353

5454
testInstance.timeout(0)
@@ -63,28 +63,28 @@ export function test(testInstance) {
6363
// check that test should actually fail
6464
try {
6565
assertThrown(err, testInstance.throws)
66-
event.emit(event.testInstance.passed, test)
67-
event.emit(event.testInstance.finished, test)
66+
event.emit(event.testInstance.passed, testInstance)
67+
event.emit(event.testInstance.finished, testInstance)
6868
recorder.add(doneFn)
6969
return
7070
} catch (newErr) {
7171
err = newErr
7272
}
7373
}
7474
testInstance.err = err
75-
event.emit(event.testInstance.failed, test, err)
76-
event.emit(event.testInstance.finished, test)
75+
event.emit(event.testInstance.failed, testInstance, err)
76+
event.emit(event.testInstance.finished, testInstance)
7777
recorder.add(() => doneFn(err))
7878
})
7979

8080
if (isAsyncFunction(testFn)) {
81-
event.emit(event.testInstance.started, test)
81+
event.emit(event.testInstance.started, testInstance)
8282
testFn
83-
.call(test, getInjectedArguments(testFn, test))
83+
.call(testInstance, getInjectedArguments(testFn, testInstance))
8484
.then(() => {
8585
recorder.add('fire testInstance.passed', () => {
86-
event.emit(event.testInstance.passed, test)
87-
event.emit(event.testInstance.finished, test)
86+
event.emit(event.testInstance.passed, testInstance)
87+
event.emit(event.testInstance.finished, testInstance)
8888
})
8989
recorder.add('finish test', doneFn)
9090
})
@@ -98,20 +98,20 @@ export function test(testInstance) {
9898
}
9999

100100
try {
101-
event.emit(event.testInstance.started, test)
102-
testFn.call(test, getInjectedArguments(testFn, test))
101+
event.emit(event.testInstance.started, testInstance)
102+
testFn.call(testInstance, getInjectedArguments(testFn, testInstance))
103103
} catch (err) {
104104
recorder.throw(err)
105105
} finally {
106106
recorder.add('fire testInstance.passed', () => {
107-
event.emit(event.testInstance.passed, test)
108-
event.emit(event.testInstance.finished, test)
107+
event.emit(event.testInstance.passed, testInstance)
108+
event.emit(event.testInstance.finished, testInstance)
109109
})
110110
recorder.add('finish test', doneFn)
111111
recorder.catch()
112112
}
113113
}
114-
return test
114+
return testInstance
115115
}
116116

117117
/**

lib/output.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const outputModule = {
2727
print,
2828
/** @type {number} */
2929
stepShift: 0,
30+
/** @type {number} */
31+
spaceShift: 100, // default width for truncating output
3032

3133
standWithUkraine() {
3234
return `#${colors.bold.yellow('StandWith')}${colors.bold.cyan('Ukraine')}`
@@ -61,7 +63,7 @@ const outputModule = {
6163
debug(msg) {
6264
const _msg = isMaskedData() ? maskSensitiveData(msg) : msg
6365
if (outputLevel >= 2) {
64-
print(' '.repeat(this.stepShift), styles.debug(`${figures.pointerSmall} ${_msg}`))
66+
print(' '.repeat(outputModule.stepShift), styles.debug(`${figures.pointerSmall} ${_msg}`))
6567
}
6668
},
6769

@@ -72,7 +74,7 @@ const outputModule = {
7274
log(msg) {
7375
const _msg = isMaskedData() ? maskSensitiveData(msg) : msg
7476
if (outputLevel >= 3) {
75-
print(' '.repeat(this.stepShift), styles.log(truncate(` ${_msg}`, this.spaceShift)))
77+
print(' '.repeat(outputModule.stepShift), styles.log(truncate(` ${_msg}`, outputModule.spaceShift)))
7678
}
7779
},
7880

@@ -118,14 +120,14 @@ const outputModule = {
118120
let stepLine = step.toCliStyled ? step.toCliStyled() : step.toString()
119121
if (step.metaStep && outputLevel >= 1) {
120122
// this.stepShift += 2;
121-
stepLine = colors.dim(truncate(stepLine, this.spaceShift))
123+
stepLine = colors.dim(truncate(stepLine, outputModule.spaceShift))
122124
}
123125
if (step.comment) {
124126
stepLine += colors.grey(step.comment.split('\n').join('\n' + ' '.repeat(4)))
125127
}
126128

127129
const _stepLine = isMaskedData() ? maskSensitiveData(stepLine) : stepLine
128-
print(' '.repeat(this.stepShift), truncate(_stepLine, this.spaceShift))
130+
print(' '.repeat(outputModule.stepShift), truncate(_stepLine, outputModule.spaceShift))
129131
},
130132

131133
/** @namespace */

test/runner/codecept_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { fileURLToPath } from 'url'
44
const { expect } = chai
55

66
import assert from 'assert'
7-
import exec from 'child_process'
7+
import { exec } from 'child_process'
88
import debug from 'debug'
9-
import event from '../../lib.js'
9+
import event from '../../lib/event.js'
1010

1111
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1212
global.codecept_dir = path.join(__dirname, '/..')

test/runner/comment_step_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import path from 'path'
22
import chai from 'chai'
33
import { fileURLToPath } from 'url'
4-
const { expect } = chai
4+
const { expect: chaiExpect } = chai
55

6-
import exec from 'child_process'
6+
import { exec } from 'child_process'
77
import { expect } from 'expect'
88

99
const __dirname = path.dirname(fileURLToPath(import.meta.url))

test/runner/consts.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import path from 'path'
22

33
const runner = path.join(process.cwd(), 'bin/codecept.js')
4-
const codecept_dir = path.join(process.cwd(), 'test/data/sandbox')
5-
const codecept_run = `${runner} run`
6-
7-
export default {
8-
codecept_run,
9-
codecept_dir,
10-
runner,
11-
}
4+
export const codecept_dir = path.join(process.cwd(), 'test/data/sandbox')
5+
export const codecept_run = `${runner} run`
6+
export { runner }

test/runner/custom-reporter-plugin_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { expect } from 'expect'
22
import chai from 'chai'
3-
import exec from 'child_process'
3+
import { exec } from 'child_process'
44
import { codecept_dir, codecept_run } from './consts.js'
55
import debug from 'debug'
66
import fs from 'fs'
77
import path from 'path'
8-
const { expect } = chai
8+
const { expect: chaiExpect } = chai
99

1010
const config_run_config = (config, grep, verbose = false) => `${codecept_run} ${verbose ? '--verbose' : ''} --config ${codecept_dir}/configs/custom-reporter-plugin/${config} ${grep ? `--grep "${grep}"` : ''}`
1111

test/runner/definitions_test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { exec, execSync } from 'child_process'
77

88
import { Project, StructureKind, ts } from 'ts-morph'
99

10+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1011
const runner = path.join(__dirname, '/../../bin/codecept.js')
1112
const codecept_dir = path.join(__dirname, '/../data/sandbox/configs/definitions')
1213
const pathToRootOfProject = path.join(__dirname, '../../')
@@ -15,11 +16,6 @@ const pathOfJSDocDefinitions = path.join(pathToRootOfProject, 'typings/types.d.t
1516
const pathToTests = path.resolve(pathToRootOfProject, 'test')
1617
const pathToTypings = path.resolve(pathToRootOfProject, 'typings')
1718

18-
if (diagnostics.length > 0) throw new Error(project.formatDiagnosticsWithColorAndContext(diagnostics))
19-
})
20-
})
21-
})
22-
2319
describe('Definitions', function () {
2420
this.timeout(30000)
2521
this.retries(4)
@@ -250,7 +246,6 @@ describe('Definitions', function () {
250246
*/
251247
function resolutionHost(moduleResolutionHost, getCompilerOptions) {
252248
return {
253-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
254249
resolveTypeReferenceDirectives: (typeDirectiveNames, containingFile) => {
255250
const compilerOptions = getCompilerOptions()
256251
const resolvedTypeReferenceDirectives = []

test/runner/dry_run_test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import path from 'path'
22
import chai from 'chai'
33
import { fileURLToPath } from 'url'
4-
const { expect } = chai
5-
64
import { expect } from 'expect'
7-
import exec from 'child_process'
5+
import { exec } from 'child_process'
6+
import char from 'figures'
87

8+
const { expect: chaiExpect } = chai
9+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
910
const runner = path.join(__dirname, '/../../bin/codecept.js')
1011
const codecept_dir = path.join(__dirname, '/../data/sandbox')
1112
const codecept_run = `${runner} dry-run`
1213
const codecept_run_config = (config, grep) => `${codecept_run} --config ${codecept_dir}/${config} ${grep ? `--grep "${grep}"` : ''}`
13-
import char from 'figures'
14-
15-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1614
describe('dry-run command', () => {
1715
before(() => {
1816
process.chdir(codecept_dir)

test/runner/init_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'url'
44
import { DOWN, ENTER } from 'inquirer-test'
55
import run from 'inquirer-test'
66
import fs from 'fs'
7-
import mkdirp from 'mkdirp'
7+
import { mkdirp } from 'mkdirp'
88

99
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1010
const runner = path.join(__dirname, '../../bin/codecept.js')

test/runner/interface_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import path from 'path'
22
import chai from 'chai'
33
import { fileURLToPath } from 'url'
4-
const { expect } = chai
4+
const { expect: chaiExpect } = chai
55

66
import { expect } from 'expect'
7-
import exec from 'child_process'
7+
import { exec } from 'child_process'
88

99
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1010
const runner = path.join(__dirname, '/../../bin/codecept.js')

0 commit comments

Comments
 (0)