( test: string, fn: (s: IIntegrationState) => Promise<void> | void, testFunction: TestFunction | ExclusiveTestFunction = it, )
| 47 | } |
| 48 | |
| 49 | const itIntegratesBasic = ( |
| 50 | test: string, |
| 51 | fn: (s: IIntegrationState) => Promise<void> | void, |
| 52 | testFunction: TestFunction | ExclusiveTestFunction = it, |
| 53 | ) => |
| 54 | testFunction(test, async function() { |
| 55 | if (!this.test?.file) { |
| 56 | throw new Error(`Could not find file for test`); |
| 57 | } |
| 58 | |
| 59 | const golden = new GoldenText( |
| 60 | this.test!.titlePath().join(' '), |
| 61 | this.test?.file!, |
| 62 | testWorkspace, |
| 63 | ); |
| 64 | const root = new TestRoot(golden, this.test!.fullTitle()); |
| 65 | await root.initialize; |
| 66 | |
| 67 | try { |
| 68 | (this.test as IGoldenReporterTextTest).goldenText = golden; |
| 69 | |
| 70 | await fn({ golden, r: root, context: this as Mocha.Context & { test: Mocha.Runnable } }); |
| 71 | } finally { |
| 72 | try { |
| 73 | await root.disconnect(); |
| 74 | } catch (e) { |
| 75 | console.warn('Error disconnecting test root:', e); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | if (golden.hasNonAssertedLogs()) { |
| 80 | throw new Error( |
| 81 | `Whoa, test "${test}" has some logs that it did not assert!\n\n${golden.getOutput()}`, |
| 82 | ); |
| 83 | } |
| 84 | }); |
| 85 | |
| 86 | itIntegratesBasic.only = (test: string, fn: (s: IIntegrationState) => Promise<void> | void) => |
| 87 | itIntegratesBasic(test, fn, it.only); |
no test coverage detected