How to use makeTempDir method in istanbul

Best JavaScript code snippet using istanbul

atom-application.test.js

Source:atom-application.test.js Github

copy

Full Screen

...14 beforeEach(function () {15 originalAppQuit = electron.app.quit16 mockElectronAppQuit()17 originalAtomHome = process.env.ATOM_HOME18 process.env.ATOM_HOME = makeTempDir('atom-home')19 // Symlinking the compile cache into the temporary home dir makes the windows load much faster20 fs.symlinkSync(path.join(originalAtomHome, 'compile-cache'), path.join(process.env.ATOM_HOME, 'compile-cache'))21 season.writeFileSync(path.join(process.env.ATOM_HOME, 'config.cson'), {22 '*': {23 welcome: {showOnStartup: false},24 core: {telemetryConsent: 'no'}25 }26 })27 atomApplicationsToDestroy = []28 })29 afterEach(async function () {30 process.env.ATOM_HOME = originalAtomHome31 for (let atomApplication of atomApplicationsToDestroy) {32 await atomApplication.destroy()33 }34 await clearElectronSession()35 electron.app.quit = originalAppQuit36 })37 describe('launch', function () {38 it('can open to a specific line number of a file', async function () {39 const filePath = path.join(makeTempDir(), 'new-file')40 fs.writeFileSync(filePath, '1\n2\n3\n4\n')41 const atomApplication = buildAtomApplication()42 const window = atomApplication.launch(parseCommandLine([filePath + ':3']))43 await focusWindow(window)44 const cursorRow = await evalInWebContents(window.browserWindow.webContents, function (sendBackToMainProcess) {45 atom.workspace.observeActivePaneItem(function (textEditor) {46 if (textEditor) sendBackToMainProcess(textEditor.getCursorBufferPosition().row)47 })48 })49 assert.equal(cursorRow, 2)50 })51 it('can open to a specific line and column of a file', async function () {52 const filePath = path.join(makeTempDir(), 'new-file')53 fs.writeFileSync(filePath, '1\n2\n3\n4\n')54 const atomApplication = buildAtomApplication()55 const window = atomApplication.launch(parseCommandLine([filePath + ':2:2']))56 await focusWindow(window)57 const cursorPosition = await evalInWebContents(window.browserWindow.webContents, function (sendBackToMainProcess) {58 atom.workspace.observeActivePaneItem(function (textEditor) {59 if (textEditor) sendBackToMainProcess(textEditor.getCursorBufferPosition())60 })61 })62 assert.deepEqual(cursorPosition, {row: 1, column: 1})63 })64 it('removes all trailing whitespace and colons from the specified path', async function () {65 let filePath = path.join(makeTempDir(), 'new-file')66 fs.writeFileSync(filePath, '1\n2\n3\n4\n')67 const atomApplication = buildAtomApplication()68 const window = atomApplication.launch(parseCommandLine([filePath + ':: ']))69 await focusWindow(window)70 const openedPath = await evalInWebContents(window.browserWindow.webContents, function (sendBackToMainProcess) {71 atom.workspace.observeActivePaneItem(function (textEditor) {72 if (textEditor) sendBackToMainProcess(textEditor.getPath())73 })74 })75 assert.equal(openedPath, filePath)76 })77 if (process.platform === 'darwin' || process.platform === 'win32') {78 it('positions new windows at an offset distance from the previous window', async function () {79 const atomApplication = buildAtomApplication()80 const window1 = atomApplication.launch(parseCommandLine([makeTempDir()]))81 await focusWindow(window1)82 window1.browserWindow.setBounds({width: 400, height: 400, x: 0, y: 0})83 const window2 = atomApplication.launch(parseCommandLine([makeTempDir()]))84 await focusWindow(window2)85 assert.notEqual(window1, window2)86 const window1Dimensions = window1.getDimensions()87 const window2Dimensions = window2.getDimensions()88 assert.isAbove(window2Dimensions.x, window1Dimensions.x)89 assert.isAbove(window2Dimensions.y, window1Dimensions.y)90 })91 }92 it('reuses existing windows when opening paths, but not directories', async function () {93 const dirAPath = makeTempDir("a")94 const dirBPath = makeTempDir("b")95 const dirCPath = makeTempDir("c")96 const existingDirCFilePath = path.join(dirCPath, 'existing-file')97 fs.writeFileSync(existingDirCFilePath, 'this is an existing file')98 const atomApplication = buildAtomApplication()99 const window1 = atomApplication.launch(parseCommandLine([path.join(dirAPath, 'new-file')]))100 await focusWindow(window1)101 let activeEditorPath102 activeEditorPath = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) {103 atom.workspace.observeActivePaneItem(function (textEditor) {104 if (textEditor) sendBackToMainProcess(textEditor.getPath())105 })106 })107 assert.equal(activeEditorPath, path.join(dirAPath, 'new-file'))108 // Reuses the window when opening *files*, even if they're in a different directory109 // Does not change the project paths when doing so.110 const reusedWindow = atomApplication.launch(parseCommandLine([existingDirCFilePath]))111 assert.equal(reusedWindow, window1)112 assert.deepEqual(atomApplication.windows, [window1])113 activeEditorPath = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) {114 atom.workspace.onDidChangeActivePaneItem(function (textEditor) {115 sendBackToMainProcess(textEditor.getPath())116 })117 })118 assert.equal(activeEditorPath, existingDirCFilePath)119 assert.deepEqual(await getTreeViewRootDirectories(window1), [dirAPath])120 // Opens new windows when opening directories121 const window2 = atomApplication.launch(parseCommandLine([dirCPath]))122 assert.notEqual(window2, window1)123 await focusWindow(window2)124 assert.deepEqual(await getTreeViewRootDirectories(window2), [dirCPath])125 })126 it('adds folders to existing windows when the --add option is used', async function () {127 const dirAPath = makeTempDir("a")128 const dirBPath = makeTempDir("b")129 const dirCPath = makeTempDir("c")130 const existingDirCFilePath = path.join(dirCPath, 'existing-file')131 fs.writeFileSync(existingDirCFilePath, 'this is an existing file')132 const atomApplication = buildAtomApplication()133 const window1 = atomApplication.launch(parseCommandLine([path.join(dirAPath, 'new-file')]))134 await focusWindow(window1)135 let activeEditorPath136 activeEditorPath = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) {137 atom.workspace.observeActivePaneItem(function (textEditor) {138 if (textEditor) sendBackToMainProcess(textEditor.getPath())139 })140 })141 assert.equal(activeEditorPath, path.join(dirAPath, 'new-file'))142 // When opening *files* with --add, reuses an existing window and adds143 // parent directory to the project144 let reusedWindow = atomApplication.launch(parseCommandLine([existingDirCFilePath, '--add']))145 assert.equal(reusedWindow, window1)146 assert.deepEqual(atomApplication.windows, [window1])147 activeEditorPath = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) {148 atom.workspace.onDidChangeActivePaneItem(function (textEditor) {149 sendBackToMainProcess(textEditor.getPath())150 })151 })152 assert.equal(activeEditorPath, existingDirCFilePath)153 assert.deepEqual(await getTreeViewRootDirectories(window1), [dirAPath, dirCPath])154 // When opening *directories* with add reuses an existing window and adds155 // the directory to the project156 reusedWindow = atomApplication.launch(parseCommandLine([dirBPath, '-a']))157 assert.equal(reusedWindow, window1)158 assert.deepEqual(atomApplication.windows, [window1])159 await conditionPromise(async () => (await getTreeViewRootDirectories(reusedWindow)).length === 3)160 assert.deepEqual(await getTreeViewRootDirectories(window1), [dirAPath, dirCPath, dirBPath])161 })162 it('persists window state based on the project directories', async function () {163 const tempDirPath = makeTempDir()164 const atomApplication = buildAtomApplication()165 const window1 = atomApplication.launch(parseCommandLine([path.join(tempDirPath, 'new-file')]))166 await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) {167 atom.workspace.observeActivePaneItem(function (textEditor) {168 if (textEditor) {169 textEditor.insertText('Hello World!')170 sendBackToMainProcess(null)171 }172 })173 })174 window1.close()175 await window1.closedPromise176 const window2 = atomApplication.launch(parseCommandLine([path.join(tempDirPath)]))177 const window2Text = await evalInWebContents(window2.browserWindow.webContents, function (sendBackToMainProcess) {178 atom.workspace.observeActivePaneItem(function (textEditor) {179 if (textEditor) sendBackToMainProcess(textEditor.getText())180 })181 })182 assert.equal(window2Text, 'Hello World!')183 })184 it('shows all directories in the tree view when multiple directory paths are passed to Atom', async function () {185 const dirAPath = makeTempDir("a")186 const dirBPath = makeTempDir("b")187 const dirBSubdirPath = path.join(dirBPath, 'c')188 fs.mkdirSync(dirBSubdirPath)189 const atomApplication = buildAtomApplication()190 const window1 = atomApplication.launch(parseCommandLine([dirAPath, dirBPath]))191 await focusWindow(window1)192 await timeoutPromise(1000)193 let treeViewPaths = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) {194 sendBackToMainProcess(195 Array196 .from(document.querySelectorAll('.tree-view .project-root > .header .name'))197 .map(element => element.dataset.path)198 )199 })200 assert.deepEqual(treeViewPaths, [dirAPath, dirBPath])201 })202 it('reuses windows with no project paths to open directories', async function () {203 const tempDirPath = makeTempDir()204 const atomApplication = buildAtomApplication()205 const window1 = atomApplication.launch(parseCommandLine([]))206 await focusWindow(window1)207 const reusedWindow = atomApplication.launch(parseCommandLine([tempDirPath]))208 assert.equal(reusedWindow, window1)209 await conditionPromise(async () => (await getTreeViewRootDirectories(reusedWindow)).length > 0)210 })211 it('opens a new window with a single untitled buffer when launched with no path, even if windows already exist', async function () {212 const atomApplication = buildAtomApplication()213 const window1 = atomApplication.launch(parseCommandLine([]))214 await focusWindow(window1)215 const window1EditorTitle = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) {216 sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle())217 })218 assert.equal(window1EditorTitle, 'untitled')219 const window2 = atomApplication.launch(parseCommandLine([]))220 await focusWindow(window2)221 const window2EditorTitle = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) {222 sendBackToMainProcess(atom.workspace.getActiveTextEditor().getTitle())223 })224 assert.equal(window2EditorTitle, 'untitled')225 assert.deepEqual(atomApplication.windows, [window1, window2])226 })227 it('does not open an empty editor when opened with no path if the core.openEmptyEditorOnStart config setting is false', async function () {228 const configPath = path.join(process.env.ATOM_HOME, 'config.cson')229 const config = season.readFileSync(configPath)230 if (!config['*'].core) config['*'].core = {}231 config['*'].core.openEmptyEditorOnStart = false232 season.writeFileSync(configPath, config)233 const atomApplication = buildAtomApplication()234 const window1 = atomApplication.launch(parseCommandLine([]))235 await focusWindow(window1)236 // wait a bit just to make sure we don't pass due to querying the render process before it loads237 await timeoutPromise(1000)238 const itemCount = await evalInWebContents(window1.browserWindow.webContents, function (sendBackToMainProcess) {239 sendBackToMainProcess(atom.workspace.getActivePane().getItems().length)240 })241 assert.equal(itemCount, 0)242 })243 it('opens an empty text editor and loads its parent directory in the tree-view when launched with a new file path', async function () {244 const atomApplication = buildAtomApplication()245 const newFilePath = path.join(makeTempDir(), 'new-file')246 const window = atomApplication.launch(parseCommandLine([newFilePath]))247 await focusWindow(window)248 const {editorTitle, editorText} = await evalInWebContents(window.browserWindow.webContents, function (sendBackToMainProcess) {249 atom.workspace.observeActivePaneItem(function (editor) {250 if (editor) sendBackToMainProcess({editorTitle: editor.getTitle(), editorText: editor.getText()})251 })252 })253 assert.equal(editorTitle, path.basename(newFilePath))254 assert.equal(editorText, '')255 assert.deepEqual(await getTreeViewRootDirectories(window), [path.dirname(newFilePath)])256 })257 it('adds a remote directory to the project when launched with a remote directory', async function () {258 const packagePath = path.join(__dirname, '..', 'fixtures', 'packages', 'package-with-directory-provider')259 const packagesDirPath = path.join(process.env.ATOM_HOME, 'packages')260 fs.mkdirSync(packagesDirPath)261 fs.symlinkSync(packagePath, path.join(packagesDirPath, 'package-with-directory-provider'))262 const atomApplication = buildAtomApplication()263 atomApplication.config.set('core.disabledPackages', ['fuzzy-finder'])264 const remotePath = 'remote://server:3437/some/directory/path'265 let window = atomApplication.launch(parseCommandLine([remotePath]))266 await focusWindow(window)267 await conditionPromise(async () => (await getProjectDirectories()).length > 0)268 let directories = await getProjectDirectories()269 assert.deepEqual(directories, [{type: 'FakeRemoteDirectory', path: remotePath}])270 await window.reload()271 await focusWindow(window)272 directories = await getProjectDirectories()273 assert.deepEqual(directories, [{type: 'FakeRemoteDirectory', path: remotePath}])274 function getProjectDirectories () {275 return evalInWebContents(window.browserWindow.webContents, function (sendBackToMainProcess) {276 sendBackToMainProcess(atom.project.getDirectories().map(d => ({ type: d.constructor.name, path: d.getPath() })))277 })278 }279 })280 it('reopens any previously opened windows when launched with no path', async function () {281 const tempDirPath1 = makeTempDir()282 const tempDirPath2 = makeTempDir()283 const atomApplication1 = buildAtomApplication()284 const app1Window1 = atomApplication1.launch(parseCommandLine([tempDirPath1]))285 await app1Window1.loadedPromise286 const app1Window2 = atomApplication1.launch(parseCommandLine([tempDirPath2]))287 await app1Window2.loadedPromise288 await app1Window1.saveState()289 await app1Window2.saveState()290 const atomApplication2 = buildAtomApplication()291 const [app2Window1, app2Window2] = atomApplication2.launch(parseCommandLine([]))292 await app2Window1.loadedPromise293 await app2Window2.loadedPromise294 assert.deepEqual(await getTreeViewRootDirectories(app2Window1), [tempDirPath1])295 assert.deepEqual(await getTreeViewRootDirectories(app2Window2), [tempDirPath2])296 })297 it('does not reopen any previously opened windows when launched with no path and `core.restorePreviousWindowsOnStart` is false', async function () {298 const atomApplication1 = buildAtomApplication()299 const app1Window1 = atomApplication1.launch(parseCommandLine([makeTempDir()]))300 await focusWindow(app1Window1)301 const app1Window2 = atomApplication1.launch(parseCommandLine([makeTempDir()]))302 await focusWindow(app1Window2)303 const configPath = path.join(process.env.ATOM_HOME, 'config.cson')304 const config = season.readFileSync(configPath)305 if (!config['*'].core) config['*'].core = {}306 config['*'].core.restorePreviousWindowsOnStart = false307 season.writeFileSync(configPath, config)308 const atomApplication2 = buildAtomApplication()309 const app2Window = atomApplication2.launch(parseCommandLine([]))310 await focusWindow(app2Window)311 assert.deepEqual(await getTreeViewRootDirectories(app2Window), [])312 })313 describe('when closing the last window', function () {314 if (process.platform === 'linux' || process.platform === 'win32') {315 it('quits the application', async function () {316 const atomApplication = buildAtomApplication()317 const window = atomApplication.launch(parseCommandLine([path.join(makeTempDir("a"), 'file-a')]))318 await focusWindow(window)319 window.close()320 await window.closedPromise321 assert(electron.app.hasQuitted())322 })323 } else if (process.platform === 'darwin') {324 it('leaves the application open', async function () {325 const atomApplication = buildAtomApplication()326 const window = atomApplication.launch(parseCommandLine([path.join(makeTempDir("a"), 'file-a')]))327 await focusWindow(window)328 window.close()329 await window.closedPromise330 assert(!electron.app.hasQuitted())331 })332 }333 })334 })335 describe('before quitting', function () {336 it('waits until all the windows have saved their state and then quits', async function () {337 const dirAPath = makeTempDir("a")338 const dirBPath = makeTempDir("b")339 const atomApplication = buildAtomApplication()340 const window1 = atomApplication.launch(parseCommandLine([path.join(dirAPath, 'file-a')]))341 await focusWindow(window1)342 const window2 = atomApplication.launch(parseCommandLine([path.join(dirBPath, 'file-b')]))343 await focusWindow(window2)344 electron.app.quit()345 assert(!electron.app.hasQuitted())346 await Promise.all([window1.lastSaveStatePromise, window2.lastSaveStatePromise])347 assert(electron.app.hasQuitted())348 })349 })350 function buildAtomApplication () {351 const atomApplication = new AtomApplication({352 resourcePath: ATOM_RESOURCE_PATH,...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const istanbulLibReport = require('istanbul-lib-report');2const tempDir = istanbulLibReport.makeTempDir();3console.log(tempDir);4const istanbulLibCoverage = require('istanbul-lib-coverage');5const tempDir = istanbulLibCoverage.makeTempDir();6console.log(tempDir);7const istanbulLibReport = require('istanbul-lib-report');8const tempDir = istanbulLibReport.makeTempDir();9console.log(tempDir);10const istanbulLibCoverage = require('istanbul-lib-coverage');11const tempDir = istanbulLibCoverage.makeTempDir();12console.log(tempDir);

Full Screen

Using AI Code Generation

copy

Full Screen

1var istanbul = require('istanbul');2var tempDir = istanbul.utils.makeTempDir();3console.log(tempDir);4var istanbul = require('istanbul');5var tempDir = istanbul.utils.makeTempDirSync();6console.log(tempDir);

Full Screen

Using AI Code Generation

copy

Full Screen

1const libReport = require('istanbul-lib-report');2const path = require('path');3const tempDir = libReport.makeTempDir();4console.log(tempDir);5console.log(path.basename(tempDir));6const libReport = require('istanbul-lib-report');7const tempDir = libReport.makeTempDir();8console.log(tempDir);

Full Screen

Using AI Code Generation

copy

Full Screen

1const istanbulLibReport = require('istanbul-lib-report');2const makeTempDir = istanbulLibReport.makeTempDir;3const tempDir = makeTempDir();4const istanbulLibReport = require('istanbul-lib-report');5const makeTempDirSync = istanbulLibReport.makeTempDirSync;6const tempDir = makeTempDirSync();7const istanbulLibReport = require('istanbul-lib-report');8const makeTempDir = istanbulLibReport.makeTempDir;9const tempDir = makeTempDir({ dir: './temp' });10const istanbulLibReport = require('istanbul-lib-report');11const makeTempDirSync = istanbulLibReport.makeTempDirSync;12const tempDir = makeTempDirSync({ dir: './temp' });

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run istanbul automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful