From 673f4f4d0c9167bc03a54e73bad4b0cab78708eb Mon Sep 17 00:00:00 2001 From: Ryohei Ikegami Date: Mon, 3 Apr 2017 19:46:24 +0900 Subject: [PATCH] Add test for `require` to search under app dir --- spec/modules-spec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/modules-spec.js b/spec/modules-spec.js index 5f8271752711..26cafc7ccb25 100644 --- a/spec/modules-spec.js +++ b/spec/modules-spec.js @@ -2,6 +2,8 @@ const assert = require('assert') const Module = require('module') const path = require('path') const temp = require('temp') +const {remote} = require('electron') +const {BrowserWindow} = remote describe('third-party module', function () { var fixtures = path.join(__dirname, 'fixtures') @@ -129,3 +131,17 @@ describe('Module._nodeModulePaths', function () { }) }) }) + +describe('require', () => { + describe('when loaded URL is not file: protocol', () => { + it('searches for module under app directory', async () => { + const w = new BrowserWindow({ + show: false, + }) + w.loadURL('about:blank') + const result = await w.webContents.executeJavaScript('typeof require("q").when') + assert.equal(result, 'function') + w.destroy() + }) + }) +})