Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    electron-tapepublic

    Electron Tape

    A tape testing harness for electron apps.

    Usage

    To use electron-tape, you create two test files: one for the main thread, and one for the ui thread.

    Both files will be loaded and run simultaneously. The test results will be output in the logs of their respective threads. Both threads will remain open so you can check the results.

    To run the tests, call electron --v=-1 <main-thread-testfile>.

    main-test.js:

    var etape    = require('electron-tape')
    var ipc      = require('ipc')
     
    etape(__dirname+'/ui-test.js', function (tape, window) {
     
      tape('send/receive data', function (t) {
        // send 1, 2, 3
        window.webContents.send('test-channel', 1)
        window.webContents.send('test-channel', 2)
        window.webContents.send('test-channel', 3)
     
        // receive 1, 2, 3
        var n = 0
        ipc.on('test-channel', function (e, v) {
          t.equal(v, ++n)
          if (=== 3)
            t.end()
        })
      })
     
    })

    ui-test.js:

    var etape    = require('electron-tape')
    var ipc      = require('ipc')
     
    etape(function (tape, window) {
     
      tape('send/receive data', function (t) {
        // send 1, 2, 3
        ipc.send('test-channel', 1)
        ipc.send('test-channel', 2)
        ipc.send('test-channel', 3)
     
        // receive 1, 2, 3
        var n = 0
        ipc.on('test-channel', function (e, v) {
          t.equal(v, ++n)
          if (=== 3)
            t.end()
        })
      })
     
    })

    Keywords

    install

    npm i electron-tape

    Downloadsweekly downloads

    0

    version

    1.0.0

    license

    MIT

    repository

    githubgithub

    last publish

    collaborators

    • avatar