({
notifyMode,
arl,
rootDir,
moduleName,
}: {arl: Array<AggregatedResult>; moduleName?: string} & Pick<
Config.GlobalConfig,
'notifyMode'
> &
Partial<Pick<Config.ProjectConfig, 'rootDir'>>)
| 69 | ]; |
| 70 | |
| 71 | const testModes = ({ |
| 72 | notifyMode, |
| 73 | arl, |
| 74 | rootDir, |
| 75 | moduleName, |
| 76 | }: {arl: Array<AggregatedResult>; moduleName?: string} & Pick< |
| 77 | Config.GlobalConfig, |
| 78 | 'notifyMode' |
| 79 | > & |
| 80 | Partial<Pick<Config.ProjectConfig, 'rootDir'>>) => { |
| 81 | const notify = require('node-notifier'); |
| 82 | |
| 83 | const globalConfig = makeGlobalConfig({notify: true, notifyMode, rootDir}); |
| 84 | |
| 85 | let previousContext = initialContext; |
| 86 | for (const [i, ar] of arl.entries()) { |
| 87 | const newContext: ReporterContext = Object.assign(previousContext, { |
| 88 | firstRun: i === 0, |
| 89 | previousSuccess: previousContext.previousSuccess, |
| 90 | }); |
| 91 | const reporter = new NotifyReporter(globalConfig, newContext); |
| 92 | previousContext = newContext; |
| 93 | const testContexts = new Set<TestContext>(); |
| 94 | |
| 95 | if (moduleName != null) { |
| 96 | testContexts.add({ |
| 97 | hasteFS: { |
| 98 | getModuleName() { |
| 99 | return moduleName; |
| 100 | }, |
| 101 | |
| 102 | matchFiles() { |
| 103 | return ['package.json']; |
| 104 | }, |
| 105 | }, |
| 106 | } as unknown as TestContext); |
| 107 | } |
| 108 | |
| 109 | reporter.onRunComplete(testContexts, ar); |
| 110 | |
| 111 | if (ar.numTotalTests === 0) { |
| 112 | expect(notify.notify).not.toHaveBeenCalled(); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | const calls: Array<any> = notify.notify.mock.calls; |
| 117 | expect( |
| 118 | calls.map(([{message, title}]) => ({ |
| 119 | message: message.replace('\u26D4\uFE0F ', '').replace('\u2705 ', ''), |
| 120 | title, |
| 121 | })), |
| 122 | ).toMatchSnapshot(); |
| 123 | }; |
| 124 | |
| 125 | test('test always', () => { |
| 126 | testModes({arl: notifyEvents, notifyMode: 'always'}); |
no test coverage detected