diff --git a/docs/Options.md b/docs/Options.md
index f176a5731b6..f6366ca2129 100644
--- a/docs/Options.md
+++ b/docs/Options.md
@@ -147,7 +147,8 @@ macOS and NSIS only. Array of option objects.
| **name** | The name. e.g. `PNG`.
| description | *windows-only.* The description.
| icon | The path to icon (`.icns` for MacOS and `.ico` for Windows), relative to `build` (build resources directory). Defaults to `${firstExt}.icns`/`${firstExt}.ico` (if several extensions specified, first is used) or to application icon.
-| role | *macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`.
+| role | *macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`. Corresponds to `CFBundleTypeRole`.
+| isPackage | *macOS-only* Whether the document is distributed as a bundle. If set to true, the bundle directory is treated as a file. Corresponds to `LSTypeIsPackage`.
### `.build.linux`
diff --git a/package.json b/package.json
index 4e91cadbc7e..77932296275 100644
--- a/package.json
+++ b/package.json
@@ -66,7 +66,7 @@
"chromium-pickle-js": "^0.2.0",
"cli-cursor": "^1.0.2",
"cuint": "^0.2.2",
- "debug": "2.4.5",
+ "debug": "2.5.1",
"electron-download-tf": "3.1.0",
"electron-macos-sign": "^1.3.4",
"fs-extra-p": "^3.0.3",
@@ -97,10 +97,10 @@
},
"devDependencies": {
"@develar/semantic-release": "^6.3.26",
- "@types/electron": "^1.4.29",
+ "@types/electron": "^1.4.30",
"@types/ini": "^1.3.29",
- "@types/jest": "^16.0.1",
- "@types/js-yaml": "^3.5.28",
+ "@types/jest": "^16.0.2",
+ "@types/js-yaml": "^3.5.29",
"@types/source-map-support": "^0.2.28",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-transform-async-to-module-method": "^6.16.0",
@@ -110,10 +110,8 @@
"babel-plugin-transform-inline-imports-commonjs": "^1.2.0",
"decompress-zip": "^0.3.0",
"depcheck": "^0.6.7",
- "diff": "^3.1.0",
"jest-cli": "^18.0.0",
"jest-environment-node-debug": "^0.0.2",
- "json8": "^0.9.2",
"path-sort": "^0.1.0",
"ts-babel": "^1.2.2",
"tslint": "^4.1.1",
diff --git a/src/metadata.ts b/src/metadata.ts
index 341691c34ec..29ae81bf80e 100755
--- a/src/metadata.ts
+++ b/src/metadata.ts
@@ -278,9 +278,14 @@ export interface FileAssociation {
readonly icon?: string
/*
- *macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`.
+ *macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`. Corresponds to `CFBundleTypeRole`.
*/
readonly role?: string
+
+ /*
+ *macOS-only* Whether the document is distributed as a bundle. If set to true, the bundle directory is treated as a file. Corresponds to `LSTypeIsPackage`.
+ */
+ readonly isPackage?: boolean
}
/*
diff --git a/src/packager/mac.ts b/src/packager/mac.ts
index ea03d2c281d..1168d52c999 100644
--- a/src/packager/mac.ts
+++ b/src/packager/mac.ts
@@ -111,13 +111,17 @@ export async function createApp(packager: PlatformPackager, appOutDir: stri
await copyFile(customIcon, path.join(resourcesPath, iconFile))
}
- // todo rename electron.icns
- return {
+ const result = {
CFBundleTypeExtensions: extensions,
CFBundleTypeName: fileAssociation.name,
CFBundleTypeRole: fileAssociation.role || "Editor",
CFBundleTypeIconFile: iconFile
}
+
+ if (fileAssociation.isPackage) {
+ result.LSTypeIsPackage = true
+ }
+ return result
})
}
diff --git a/test/out/__snapshots__/BuildTest.js.snap b/test/out/__snapshots__/BuildTest.js.snap
new file mode 100644
index 00000000000..e93478beef4
--- /dev/null
+++ b/test/out/__snapshots__/BuildTest.js.snap
@@ -0,0 +1,205 @@
+exports[`test cli 1`] = `
+Object {
+ "draft": undefined,
+ "extraMetadata": undefined,
+ "prerelease": undefined,
+ "publish": undefined,
+ "targets": Map {
+ Platform {
+ "buildConfigurationKey": "mac",
+ "name": "mac",
+ "nodeName": "darwin",
+ } => Map {
+ 1 => Array [],
+ },
+ },
+}
+`;
+
+exports[`test cli 2`] = `
+Object {
+ "draft": undefined,
+ "extraMetadata": undefined,
+ "prerelease": undefined,
+ "publish": undefined,
+ "targets": Map {
+ Platform {
+ "buildConfigurationKey": "mac",
+ "name": "mac",
+ "nodeName": "darwin",
+ } => Map {
+ 1 => Array [
+ "dir",
+ ],
+ },
+ },
+}
+`;
+
+exports[`test cli 3`] = `
+Object {
+ "draft": undefined,
+ "extraMetadata": undefined,
+ "prerelease": undefined,
+ "publish": undefined,
+ "targets": Map {
+ Platform {
+ "buildConfigurationKey": "linux",
+ "name": "linux",
+ "nodeName": "linux",
+ } => Map {
+ 1 => Array [
+ "dir",
+ ],
+ },
+ },
+}
+`;
+
+exports[`test cli 4`] = `
+Object {
+ "draft": undefined,
+ "extraMetadata": undefined,
+ "prerelease": undefined,
+ "publish": undefined,
+ "targets": Map {
+ Platform {
+ "buildConfigurationKey": "linux",
+ "name": "linux",
+ "nodeName": "linux",
+ } => Map {
+ 1 => Array [],
+ },
+ },
+}
+`;
+
+exports[`test cli 5`] = `
+Object {
+ "draft": undefined,
+ "extraMetadata": undefined,
+ "prerelease": undefined,
+ "publish": undefined,
+ "targets": Map {
+ Platform {
+ "buildConfigurationKey": "win",
+ "name": "windows",
+ "nodeName": "win32",
+ } => Map {
+ 1 => Array [],
+ },
+ },
+}
+`;
+
+exports[`test cli 6`] = `
+Object {
+ "draft": undefined,
+ "extraMetadata": undefined,
+ "prerelease": undefined,
+ "publish": undefined,
+ "targets": Map {
+ Platform {
+ "buildConfigurationKey": "mac",
+ "name": "mac",
+ "nodeName": "darwin",
+ } => Map {
+ 1 => Array [],
+ },
+ Platform {
+ "buildConfigurationKey": "linux",
+ "name": "linux",
+ "nodeName": "linux",
+ } => Map {
+ 1 => Array [],
+ },
+ Platform {
+ "buildConfigurationKey": "win",
+ "name": "windows",
+ "nodeName": "win32",
+ } => Map {
+ 1 => Array [],
+ },
+ },
+}
+`;
+
+exports[`test cli 7`] = `
+Object {
+ "draft": undefined,
+ "extraMetadata": undefined,
+ "prerelease": undefined,
+ "publish": undefined,
+ "targets": Map {
+ Platform {
+ "buildConfigurationKey": "linux",
+ "name": "linux",
+ "nodeName": "linux",
+ } => Map {
+ 0 => Array [
+ "tar.gz",
+ ],
+ },
+ },
+}
+`;
+
+exports[`test cli 8`] = `
+Object {
+ "draft": undefined,
+ "extraMetadata": undefined,
+ "prerelease": undefined,
+ "publish": undefined,
+ "targets": Map {
+ Platform {
+ "buildConfigurationKey": "linux",
+ "name": "linux",
+ "nodeName": "linux",
+ } => Map {
+ 1 => Array [
+ "tar.gz",
+ ],
+ },
+ },
+}
+`;
+
+exports[`test cli 9`] = `
+Object {
+ "draft": undefined,
+ "extraMetadata": undefined,
+ "prerelease": undefined,
+ "publish": undefined,
+ "targets": Map {
+ Platform {
+ "buildConfigurationKey": "linux",
+ "name": "linux",
+ "nodeName": "linux",
+ } => Map {
+ 1 => Array [
+ "tar.gz",
+ ],
+ },
+ },
+}
+`;
+
+exports[`test cli 10`] = `
+Object {
+ "draft": undefined,
+ "extraMetadata": undefined,
+ "prerelease": undefined,
+ "publish": undefined,
+ "targets": Map {
+ Platform {
+ "buildConfigurationKey": "win",
+ "name": "windows",
+ "nodeName": "win32",
+ } => Map {
+ 1 => Array [
+ "tar.gz",
+ ],
+ },
+ },
+}
+`;
diff --git a/test/out/__snapshots__/RepoSlugTest.js.snap b/test/out/__snapshots__/RepoSlugTest.js.snap
new file mode 100644
index 00000000000..37f45d3c3be
--- /dev/null
+++ b/test/out/__snapshots__/RepoSlugTest.js.snap
@@ -0,0 +1,65 @@
+exports[`test repo slug from APPVEYOR 1`] = `
+Object {
+ "auth": null,
+ "browsetemplate": "https://{domain}/{user}/{project}{/tree/committish}",
+ "bugstemplate": "https://{domain}/{user}/{project}/issues",
+ "committish": null,
+ "default": "shortcut",
+ "docstemplate": "https://{domain}/{user}/{project}{/tree/committish}#readme",
+ "domain": "github.com",
+ "filetemplate": "https://{auth@}raw.githubusercontent.com/{user}/{project}/{committish}/{path}",
+ "gittemplate": "git://{auth@}{domain}/{user}/{project}.git{#committish}",
+ "httpstemplate": "git+https://{auth@}{domain}/{user}/{project}.git{#committish}",
+ "pathmatch": /^[\\/]([^\\/]+)[\\/]([^\\/]+?)(?:[.]git)?$/,
+ "pathtemplate": "{user}/{project}{#committish}",
+ "project": "travis-build",
+ "protocols": Array [
+ "git",
+ "http",
+ "git+ssh",
+ "git+https",
+ "ssh",
+ "https",
+ ],
+ "protocols_re": /^(git|http|git\\+ssh|git\\+https|ssh|https):$/,
+ "shortcuttemplate": "{type}:{user}/{project}{#committish}",
+ "sshtemplate": "git@{domain}:{user}/{project}.git{#committish}",
+ "sshurltemplate": "git+ssh://git@{domain}/{user}/{project}.git{#committish}",
+ "treepath": "tree",
+ "type": "github",
+ "user": "travis-ci",
+}
+`;
+
+exports[`test repo slug from TRAVIS_REPO_SLUG 1`] = `
+Object {
+ "auth": null,
+ "browsetemplate": "https://{domain}/{user}/{project}{/tree/committish}",
+ "bugstemplate": "https://{domain}/{user}/{project}/issues",
+ "committish": null,
+ "default": "shortcut",
+ "docstemplate": "https://{domain}/{user}/{project}{/tree/committish}#readme",
+ "domain": "github.com",
+ "filetemplate": "https://{auth@}raw.githubusercontent.com/{user}/{project}/{committish}/{path}",
+ "gittemplate": "git://{auth@}{domain}/{user}/{project}.git{#committish}",
+ "httpstemplate": "git+https://{auth@}{domain}/{user}/{project}.git{#committish}",
+ "pathmatch": /^[\\/]([^\\/]+)[\\/]([^\\/]+?)(?:[.]git)?$/,
+ "pathtemplate": "{user}/{project}{#committish}",
+ "project": "travis-build",
+ "protocols": Array [
+ "git",
+ "http",
+ "git+ssh",
+ "git+https",
+ "ssh",
+ "https",
+ ],
+ "protocols_re": /^(git|http|git\\+ssh|git\\+https|ssh|https):$/,
+ "shortcuttemplate": "{type}:{user}/{project}{#committish}",
+ "sshtemplate": "git@{domain}:{user}/{project}.git{#committish}",
+ "sshurltemplate": "git+ssh://git@{domain}/{user}/{project}.git{#committish}",
+ "treepath": "tree",
+ "type": "github",
+ "user": "travis-ci",
+}
+`;
diff --git a/test/out/__snapshots__/extraMetadataTest.js.snap b/test/out/__snapshots__/extraMetadataTest.js.snap
new file mode 100644
index 00000000000..05841269787
--- /dev/null
+++ b/test/out/__snapshots__/extraMetadataTest.js.snap
@@ -0,0 +1,30 @@
+exports[`test extra metadata 1`] = `
+Object {
+ "author": "Foo Bar ",
+ "build": Object {
+ "appId": "org.electron-builder.testApp",
+ "compression": "store",
+ "electronVersion": "1.4.12",
+ "iconUrl": "https://raw.githubusercontent.com/szwacz/electron-boilerplate/master/resources/windows/icon.ico",
+ "linux": Object {
+ "category": "Development",
+ "packageCategory": "devel",
+ },
+ "mac": Object {
+ "category": "your.app.category.type",
+ },
+ "npmRebuild": false,
+ },
+ "description": "Test Application (test quite \" #378)",
+ "foo": Object {
+ "bar": 12,
+ "existingProp": 22,
+ },
+ "homepage": "http://foo.example.com",
+ "license": "MIT",
+ "name": "TestApp",
+ "private": true,
+ "productName": "Test App ß/W",
+ "version": "1.1.0",
+}
+`;
diff --git a/test/out/__snapshots__/globTest.js.snap b/test/out/__snapshots__/globTest.js.snap
new file mode 100644
index 00000000000..7dc390e2ba6
--- /dev/null
+++ b/test/out/__snapshots__/globTest.js.snap
@@ -0,0 +1,5 @@
+exports[`test link 1`] = `
+Object {
+ "link": "index.js",
+}
+`;
diff --git a/test/out/__snapshots__/nsisUpdaterTest.js.snap b/test/out/__snapshots__/nsisUpdaterTest.js.snap
new file mode 100644
index 00000000000..67382edc4a9
--- /dev/null
+++ b/test/out/__snapshots__/nsisUpdaterTest.js.snap
@@ -0,0 +1,23 @@
+exports[`test file url 1`] = `
+Object {
+ "name": "TestApp Setup 1.1.0.exe",
+ "sha2": "01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b",
+ "url": "https://dl.bintray.com/actperepo/generic/TestApp Setup 1.1.0.exe",
+}
+`;
+
+exports[`test file url generic 1`] = `
+Object {
+ "name": "TestApp Setup 1.1.0.exe",
+ "sha2": "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2",
+ "url": "https://develar.s3.amazonaws.com/test/TestApp Setup 1.1.0.exe",
+}
+`;
+
+exports[`test file url github 1`] = `
+Object {
+ "name": "TestApp-Setup-1.1.0.exe",
+ "sha2": "f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2",
+ "url": "https://github.com/develar/__test_nsis_release/releases/download/v1.1.0/TestApp-Setup-1.1.0.exe",
+}
+`;
diff --git a/test/out/mac/__snapshots__/macPackagerTest.js.snap b/test/out/mac/__snapshots__/macPackagerTest.js.snap
index dfa74604e98..5b76dc962f8 100644
--- a/test/out/mac/__snapshots__/macPackagerTest.js.snap
+++ b/test/out/mac/__snapshots__/macPackagerTest.js.snap
@@ -11,6 +11,15 @@ Object {
"CFBundleTypeName": "Foo",
"CFBundleTypeRole": "Viewer",
},
+ Object {
+ "CFBundleTypeExtensions": Array [
+ "boo",
+ ],
+ "CFBundleTypeIconFile": "Test App ßW.icns",
+ "CFBundleTypeName": "Boo",
+ "CFBundleTypeRole": "Shell",
+ "LSTypeIsPackage": true,
+ },
],
"CFBundleExecutable": "Test App ßW",
"CFBundleIconFile": "Test App ßW.icns",
diff --git a/test/out/windows/__snapshots__/nsisTest.js.snap b/test/out/windows/__snapshots__/nsisTest.js.snap
new file mode 100644
index 00000000000..3b93d8a5f1a
--- /dev/null
+++ b/test/out/windows/__snapshots__/nsisTest.js.snap
@@ -0,0 +1,7 @@
+exports[`test one-click 1`] = `
+Object {
+ "owner": "actperepo",
+ "package": "TestApp",
+ "provider": "bintray",
+}
+`;
diff --git a/test/src/ArtifactPublisherTest.ts b/test/src/ArtifactPublisherTest.ts
index b94c45c4a53..dda1592fce9 100644
--- a/test/src/ArtifactPublisherTest.ts
+++ b/test/src/ArtifactPublisherTest.ts
@@ -1,6 +1,5 @@
import { GitHubPublisher } from "out/publish/gitHubPublisher"
import { join } from "path"
-import { assertThat } from "./helpers/fileAssert"
import { BintrayPublisher } from "out/publish/BintrayPublisher"
import { createPublisher } from "out/builder"
import isCi from "is-ci"
@@ -94,7 +93,7 @@ testAndIgnoreApiRate("prerelease", async () => {
try {
await publisher.upload(iconPath)
const r = await publisher.getRelease()
- assertThat(r).hasProperties({
+ expect(r).toMatchObject({
prerelease: true,
draft: false,
})
@@ -124,7 +123,7 @@ it("create publisher", async () => {
}
const publisher = await createPublisher(packager, {provider: "github", vPrefixedTagName: false, token: "__test__"}, {})
- assertThat(publisher).hasProperties({
+ expect(publisher).toMatchObject({
info: {
provider: "github",
vPrefixedTagName: false,
diff --git a/test/src/BuildTest.ts b/test/src/BuildTest.ts
index ef69abe0c11..cd8460a1606 100644
--- a/test/src/BuildTest.ts
+++ b/test/src/BuildTest.ts
@@ -12,17 +12,22 @@ import { move, outputJson } from "fs-extra-p"
import BluebirdPromise from "bluebird-lst-c"
import * as path from "path"
import { assertThat } from "./helpers/fileAssert"
-import { archFromString, BuildOptions, Platform, Arch, PackagerOptions, DIR_TARGET, createTargets } from "out"
+import { BuildOptions, Platform, PackagerOptions, DIR_TARGET } from "out"
import { normalizeOptions } from "out/builder"
import { createYargs } from "out/cli/cliOptions"
import { extractFile } from "asar-electron-builder"
import { ELECTRON_VERSION } from "./helpers/config"
import isCi from "is-ci"
import { checkWineVersion } from "out/packager"
+import { Arch } from "out/metadata"
test("cli", async () => {
const yargs = createYargs()
+ function parse(input: string): BuildOptions {
+ return normalizeOptions(yargs.parse(input.split(" ")))
+ }
+
function expected(opt: BuildOptions): any {
return Object.assign({
publish: undefined,
@@ -32,39 +37,33 @@ test("cli", async () => {
}, opt)
}
- function parse(input: string): BuildOptions {
- return normalizeOptions(yargs.parse(input.split(" ")))
- }
+ expect(parse("--platform mac")).toMatchSnapshot()
- assertThat(parse("--platform mac")).isEqualTo(expected({targets: Platform.MAC.createTarget()}))
+ expect(parse("-owl --x64 --ia32"))
+ expect(parse("-mwl --x64 --ia32"))
- const all = expected({targets: new Map([...Platform.MAC.createTarget(null, Arch.x64), ...Platform.WINDOWS.createTarget(null, Arch.x64, Arch.ia32), ...Platform.LINUX.createTarget(null, Arch.x64, Arch.ia32)])})
- assertThat(parse("-owl --x64 --ia32")).isEqualTo(all)
- assertThat(parse("-mwl --x64 --ia32")).isEqualTo(all)
+ expect(parse("--dir")).toMatchObject(expected({targets: Platform.current().createTarget(DIR_TARGET)}))
+ expect(parse("--mac --dir")).toMatchSnapshot()
+ expect(parse("--ia32 --dir")).toMatchObject(expected({targets: Platform.current().createTarget(DIR_TARGET, Arch.ia32)}))
+ expect(parse("--platform linux --dir")).toMatchSnapshot()
- assertThat(parse("--dir")).isEqualTo(expected({targets: Platform.current().createTarget(DIR_TARGET)}))
- assertThat(parse("--mac --dir")).isEqualTo(expected({targets: Platform.MAC.createTarget(DIR_TARGET)}))
- assertThat(parse("--ia32 --dir")).isEqualTo(expected({targets: Platform.current().createTarget(DIR_TARGET, Arch.ia32)}))
- assertThat(parse("--platform linux --dir")).isEqualTo(expected({targets: Platform.LINUX.createTarget(DIR_TARGET)}))
-
- assertThat(parse("--arch x64")).isEqualTo(expected({targets: Platform.current().createTarget(null, Arch.x64)}))
- assertThat(parse("--ia32 --x64")).isEqualTo(expected({targets: Platform.current().createTarget(null, Arch.x64, Arch.ia32)}))
- assertThat(parse("--linux")).isEqualTo(expected({targets: Platform.LINUX.createTarget()}))
- assertThat(parse("--win")).isEqualTo(expected({targets: Platform.WINDOWS.createTarget()}))
- assertThat(parse("-owl")).isEqualTo(expected({targets: createTargets([Platform.MAC, Platform.WINDOWS, Platform.LINUX])}))
- assertThat(parse("-l tar.gz:ia32")).isEqualTo(expected({targets: Platform.LINUX.createTarget("tar.gz", Arch.ia32)}))
- assertThat(parse("-l tar.gz:x64")).isEqualTo(expected({targets: Platform.LINUX.createTarget("tar.gz", Arch.x64)}))
- assertThat(parse("-l tar.gz")).isEqualTo(expected({targets: Platform.LINUX.createTarget("tar.gz", archFromString(process.arch))}))
- assertThat(parse("-w tar.gz:x64")).isEqualTo(expected({targets: Platform.WINDOWS.createTarget("tar.gz", Arch.x64)}))
+ expect(parse("--arch x64")).toMatchObject(expected({targets: Platform.current().createTarget(null, Arch.x64)}))
+ expect(parse("--ia32 --x64")).toMatchObject(expected({targets: Platform.current().createTarget(null, Arch.x64, Arch.ia32)}))
+ expect(parse("--linux")).toMatchSnapshot()
+ expect(parse("--win")).toMatchSnapshot()
+ expect(parse("-owl")).toMatchSnapshot()
+ expect(parse("-l tar.gz:ia32")).toMatchSnapshot()
+ expect(parse("-l tar.gz:x64")).toMatchSnapshot()
+ expect(parse("-l tar.gz")).toMatchSnapshot()
+ expect(parse("-w tar.gz:x64")).toMatchSnapshot()
function parseExtraMetadata(input: string) {
const result = parse(input)
delete result.targets
return result
}
- assertThat(parseExtraMetadata("--em.foo=bar")).isEqualTo(expected({extraMetadata: {
- foo: "bar",
- }}))
+
+ expect(parseExtraMetadata("--em.foo=bar"))
})
// only dir - avoid DMG
@@ -203,7 +202,7 @@ test.ifDevOrLinuxCi("smart unpack", () => {
}
}),
packed: context => {
- assertThat(JSON.parse(extractFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "node_modules/debug/package.json").toString())).hasProperties({
+ expect(JSON.parse(extractFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "node_modules/debug/package.json").toString())).toMatchObject({
name: "debug"
})
return BluebirdPromise.resolve()
diff --git a/test/src/RepoSlugTest.ts b/test/src/RepoSlugTest.ts
index 69cfc2e6d0e..3b742ba069f 100644
--- a/test/src/RepoSlugTest.ts
+++ b/test/src/RepoSlugTest.ts
@@ -1,4 +1,3 @@
-import { assertThat } from "./helpers/fileAssert"
import { getRepositoryInfo } from "out/repositoryInfo"
test("repo slug from TRAVIS_REPO_SLUG", async () => {
@@ -6,10 +5,7 @@ test("repo slug from TRAVIS_REPO_SLUG", async () => {
try {
process.env.TRAVIS_REPO_SLUG = "travis-ci/travis-build"
const info = await getRepositoryInfo()
- assertThat(info).hasProperties({
- user: "travis-ci",
- project: "travis-build",
- })
+ expect(info).toMatchSnapshot()
}
finally {
if (oldValue != null) {
@@ -30,10 +26,7 @@ test("repo slug from APPVEYOR", async () => {
process.env.APPVEYOR_ACCOUNT_NAME = "travis-ci"
process.env.APPVEYOR_PROJECT_NAME = "travis-build"
const info = await getRepositoryInfo()
- assertThat(info).hasProperties({
- user: "travis-ci",
- project: "travis-build",
- })
+ expect(info).toMatchSnapshot()
}
finally {
restoreEnv("APPVEYOR_ACCOUNT_NAME", oldAppveyorAccountName)
diff --git a/test/src/extraMetadataTest.ts b/test/src/extraMetadataTest.ts
index ef981dee3bc..63302b7b584 100644
--- a/test/src/extraMetadataTest.ts
+++ b/test/src/extraMetadataTest.ts
@@ -25,12 +25,7 @@ test.ifDevOrLinuxCi("extra metadata", app({
}),
packed: async context => {
await assertThat(path.join(context.getContent(Platform.LINUX), "new-name")).isFile()
- assertThat(JSON.parse(extractFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "package.json").toString())).hasProperties({
- foo: {
- bar: 12,
- existingProp: 22,
- }
- })
+ expect(JSON.parse(extractFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "package.json").toString())).toMatchSnapshot()
}
}))
diff --git a/test/src/globTest.ts b/test/src/globTest.ts
index 3af53589f03..b06fa17142e 100644
--- a/test/src/globTest.ts
+++ b/test/src/globTest.ts
@@ -55,9 +55,7 @@ test.ifNotWindows("link", app({
return symlink(path.join(projectDir, "index.js"), path.join(projectDir, "foo.js"))
},
packed: async context => {
- assertThat(statFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "foo.js", false)).hasProperties({
- link: "index.js",
- })
+ expect(statFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "foo.js", false)).toMatchSnapshot()
},
}))
diff --git a/test/src/helpers/checkDeps.ts b/test/src/helpers/checkDeps.ts
index 1fb36d20f08..38e928ea54e 100644
--- a/test/src/helpers/checkDeps.ts
+++ b/test/src/helpers/checkDeps.ts
@@ -9,9 +9,7 @@ const knownUnusedDevDependencies = new Set([
"@develar/types",
"jest-cli",
"decompress-zip",
- "diff",
"husky",
- "json8",
"path-sort",
"typescript",
"tslint",
diff --git a/test/src/helpers/fileAssert.ts b/test/src/helpers/fileAssert.ts
index c3ddeb73d3f..adcb8e60e2e 100644
--- a/test/src/helpers/fileAssert.ts
+++ b/test/src/helpers/fileAssert.ts
@@ -1,8 +1,4 @@
import { stat, Stats } from "fs-extra-p"
-import * as json8 from "json8"
-import { green, red, gray } from "chalk"
-import { diffJson } from "diff"
-import { AssertionError } from "assert"
import * as path from "path"
import { exists } from "out/util/fs"
@@ -11,38 +7,12 @@ export function assertThat(actual: any): Assertions {
return new Assertions(actual)
}
-//noinspection JSUnusedLocalSymbols
-function jsonReplacer(key: any, value: any): any {
- if (value instanceof Map) {
- return [...value]
- }
- return value === undefined ? undefined : value
-}
-
class Assertions {
constructor (private actual: any) {
}
- isEqualTo(expected: any) {
- compare(this.actual, expected)
- }
-
- isNotEmpty() {
- compare(this.actual, "", true)
- }
-
containsAll(expected: Iterable) {
- compare(this.actual.slice().sort(), Array.from(expected).slice().sort())
- }
-
- hasProperties(expected: any) {
- const actual = Object.create(null)
- for (const name of Object.getOwnPropertyNames(this.actual)) {
- if (name in expected) {
- actual[name] = this.actual[name]
- }
- }
- compare(actual, expected)
+ expect(this.actual.slice().sort()).toEqual(Array.from(expected).slice().sort())
}
isAbsolute() {
@@ -90,31 +60,4 @@ class Assertions {
}
}).toThrowError(error)
}
-}
-
-export function prettyDiff(actual: any, expected: any): string {
- const diffJson2 = diffJson(expected, actual)
- const diff = diffJson2.map(part => {
- if (part.added) {
- return green(part.value.replace(/.+/g, " - $&"))
- }
- if (part.removed) {
- return red(part.value.replace(/.+/g, " + $&"))
- }
- return gray(part.value.replace(/.+/g, " | $&"))
- }).join("")
- return `\n${diff}\n`
-}
-
-function compare(actual: any, expected: any, not: boolean = false) {
- if (json8.equal(actual, expected) === not) {
- const actualJson = JSON.stringify(actual, jsonReplacer, 2)
- const expectedJson = JSON.stringify(expected, jsonReplacer, 2)
- const stack = new Error().stack
- throw new AssertionError({
- message: `Expected \n${expectedJson}\n\nis not equal to\n\n${actualJson}\n\n${prettyDiff(JSON.parse(expectedJson), JSON.parse(actualJson))}\n${stack.split("\n")[3].trim()}`,
- actual: actual,
- expected: expected,
- })
- }
}
\ No newline at end of file
diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts
index c9dfda0a2fe..93f809fb343 100755
--- a/test/src/helpers/packTester.ts
+++ b/test/src/helpers/packTester.ts
@@ -243,7 +243,7 @@ async function checkLinuxResult(outDir: string, packager: Packager, checkOptions
expect(await getContents(`${outDir}/TestApp_${appInfo.version}_i386.deb`)).toEqual(expectedContents)
}
- assertThat(parseDebControl(await exec("dpkg", ["--info", packageFile]))).hasProperties({
+ expect(parseDebControl(await exec("dpkg", ["--info", packageFile]))).toMatchObject({
License: "MIT",
Homepage: "http://foo.example.com",
Maintainer: "Foo Bar ",
@@ -278,7 +278,7 @@ async function checkMacResult(packager: Packager, packagerOptions: PackagerOptio
const appInfo = packager.appInfo
const packedAppDir = path.join(path.dirname(artifacts[0].file), `${appInfo.productFilename}.app`)
const info = parsePlist(await readFile(path.join(packedAppDir, "Contents", "Info.plist"), "utf8"))
- assertThat(info).hasProperties({
+ expect(info).toMatchObject({
CFBundleDisplayName: appInfo.productName,
CFBundleIdentifier: "org.electron-builder.testApp",
LSApplicationCategoryType: "your.app.category.type",
diff --git a/test/src/mac/CodeSignTest.ts b/test/src/mac/CodeSignTest.ts
index a8fd5304ea5..fcd9fd927d0 100644
--- a/test/src/mac/CodeSignTest.ts
+++ b/test/src/mac/CodeSignTest.ts
@@ -1,5 +1,4 @@
import { createKeychain } from "out/codeSign"
-import { assertThat } from "../helpers/fileAssert"
import { CSC_LINK } from "../helpers/codeSignData"
import { removePassword } from "out/util/util"
import { TmpDir } from "out/util/tmp"
@@ -14,12 +13,12 @@ const tmpDir = new TmpDir()
test.ifMac("create keychain", async () => {
const result = await createKeychain(tmpDir, CSC_LINK, process.env.CSC_KEY_PASSWORD)
- assertThat(result.keychainName).isNotEmpty()
+ expect(result.keychainName).not.toEqual("")
})
test.ifMac("create keychain with installers", async () => {
const result = await createKeychain(tmpDir, CSC_LINK, process.env.CSC_KEY_PASSWORD)
- assertThat(result.keychainName).isNotEmpty()
+ expect(result.keychainName).not.toEqual("")
})
test.ifDevOrLinuxCi("remove password from log", async () => {
diff --git a/test/src/mac/macPackagerTest.ts b/test/src/mac/macPackagerTest.ts
index 975c1f5c1d7..4cd9e5092f2 100644
--- a/test/src/mac/macPackagerTest.ts
+++ b/test/src/mac/macPackagerTest.ts
@@ -17,6 +17,12 @@ test.ifMac("one-package", app({
name: "Foo",
role: "Viewer",
},
+ {
+ ext: "boo",
+ name: "Boo",
+ role: "Shell",
+ isPackage: true,
+ },
]
}
}
diff --git a/test/src/mac/masTest.ts b/test/src/mac/masTest.ts
index 002aa8f8738..fbc45f3bb02 100644
--- a/test/src/mac/masTest.ts
+++ b/test/src/mac/masTest.ts
@@ -2,7 +2,6 @@ import { assertPack, signed, CheckingMacPackager, createMacTargetTest } from "..
import { writeFile } from "fs-extra-p"
import * as path from "path"
import BluebirdPromise from "bluebird-lst-c"
-import { assertThat } from "../helpers/fileAssert"
import { Platform } from "out"
if (process.platform !== "darwin") {
@@ -35,7 +34,7 @@ test("custom mas", () => {
}
}), {
packed: () => {
- assertThat(platformPackager.effectiveSignOptions).hasProperties({
+ expect(platformPackager.effectiveSignOptions).toMatchObject({
entitlements: "mas-entitlements file path",
"entitlements-inherit": "mas-entitlementsInherit file path",
})
@@ -57,7 +56,7 @@ test("entitlements in the package.json", () => {
}
}), {
packed: () => {
- assertThat(platformPackager.effectiveSignOptions).hasProperties({
+ expect(platformPackager.effectiveSignOptions).toMatchObject({
entitlements: "osx-entitlements file path",
"entitlements-inherit": "osx-entitlementsInherit file path",
})
@@ -77,7 +76,7 @@ test("entitlements in build dir", () => {
writeFile(path.join(projectDir, "build", "entitlements.mac.inherit.plist"), ""),
]),
packed: context => {
- assertThat(platformPackager.effectiveSignOptions).hasProperties({
+ expect(platformPackager.effectiveSignOptions).toMatchObject({
entitlements: path.join(context.projectDir, "build", "entitlements.mac.plist"),
"entitlements-inherit": path.join(context.projectDir, "build", "entitlements.mac.inherit.plist"),
})
diff --git a/test/src/nsisUpdaterTest.ts b/test/src/nsisUpdaterTest.ts
index c4d5990c903..220184e3282 100644
--- a/test/src/nsisUpdaterTest.ts
+++ b/test/src/nsisUpdaterTest.ts
@@ -65,9 +65,7 @@ test("file url", async () => {
}
const updateCheckResult = await updater.checkForUpdates()
- assertThat(updateCheckResult.fileInfo).hasProperties({
- url: "https://dl.bintray.com/actperepo/generic/TestApp Setup 1.1.0.exe"
- })
+ expect(updateCheckResult.fileInfo).toMatchSnapshot()
await assertThat(path.join(await updateCheckResult.downloadPromise)).isFile()
expect(actualEvents).toEqual(expectedEvents)
@@ -92,9 +90,7 @@ test("file url generic", async () => {
}
const updateCheckResult = await updater.checkForUpdates()
- assertThat(updateCheckResult.fileInfo).hasProperties({
- url: "https://develar.s3.amazonaws.com/test/TestApp Setup 1.1.0.exe"
- })
+ expect(updateCheckResult.fileInfo).toMatchSnapshot()
await assertThat(path.join(await updateCheckResult.downloadPromise)).isFile()
expect(actualEvents).toEqual(expectedEvents)
@@ -120,9 +116,7 @@ test("file url github", async () => {
}
const updateCheckResult = await updater.checkForUpdates()
- assertThat(updateCheckResult.fileInfo).hasProperties({
- url: "https://github.com/develar/__test_nsis_release/releases/download/v1.1.0/TestApp-Setup-1.1.0.exe"
- })
+ expect(updateCheckResult.fileInfo).toMatchSnapshot()
await assertThat(path.join(await updateCheckResult.downloadPromise)).isFile()
expect(actualEvents).toEqual(expectedEvents)
diff --git a/test/src/windows/nsisTest.ts b/test/src/windows/nsisTest.ts
index cca6cdc77ba..f98ece0d5f3 100644
--- a/test/src/windows/nsisTest.ts
+++ b/test/src/windows/nsisTest.ts
@@ -29,11 +29,7 @@ test("one-click", app({
packed: async (context) => {
await doTest(context.outDir, true)
- assertThat(safeLoad(await readFile(path.join(context.getResources(Platform.WINDOWS, Arch.ia32), "app-update.yml"), "utf-8"))).hasProperties({
- provider: "bintray",
- owner: "actperepo",
- package: "TestApp",
- })
+ expect(safeLoad(await readFile(path.join(context.getResources(Platform.WINDOWS, Arch.ia32), "app-update.yml"), "utf-8"))).toMatchSnapshot()
}
}))
@@ -65,16 +61,16 @@ test.ifDevOrLinuxCi("perMachine, no run after finish", app({
)])
},
packed: async(context) => {
- assertThat(safeLoad(await readFile(path.join(context.getResources(Platform.WINDOWS, Arch.ia32), "app-update.yml"), "utf-8"))).hasProperties({
- provider: "generic",
- url: "https://develar.s3.amazonaws.com/test",
- })
+ expect(safeLoad(await readFile(path.join(context.getResources(Platform.WINDOWS, Arch.ia32), "app-update.yml"), "utf-8"))).toMatchObject({
+ provider: "generic",
+ url: "https://develar.s3.amazonaws.com/test",
+ })
const updateInfo = safeLoad(await readFile(path.join(context.outDir, "latest.yml"), "utf-8"))
- assertThat(updateInfo).hasProperties({
- version: "1.1.0",
- path: "TestApp Setup 1.1.0.exe",
- })
- assertThat(updateInfo.sha2).isNotEmpty()
+ expect(updateInfo).toMatchObject({
+ version: "1.1.0",
+ path: "TestApp Setup 1.1.0.exe",
+ })
+ expect(updateInfo.sha2).not.toEqual("")
await doTest(context.outDir, false)
},
}))
@@ -103,7 +99,7 @@ async function doTest(outDir: string, perUser: boolean) {
const instDir = perUser ? path.join(wine.userDir, "Local Settings", "Application Data", "Programs") : path.join(driveC, "Program Files")
const appAsar = path.join(instDir, "TestApp", "1.1.0", "resources", "app.asar")
- assertThat(JSON.parse(extractFile(appAsar, "package.json").toString())).hasProperties({
+ expect(JSON.parse(extractFile(appAsar, "package.json").toString())).toMatchObject({
name: "TestApp"
})
diff --git a/test/typings/jest-ex.d.ts b/test/typings/jest-ex.d.ts
index a4a6a82079b..cb62b4c5aa2 100644
--- a/test/typings/jest-ex.d.ts
+++ b/test/typings/jest-ex.d.ts
@@ -10,4 +10,8 @@ declare module jest {
ifWinCi: jest.It
ifDevOrLinuxCi: jest.It
}
+
+ interface Matchers {
+ toMatchObject(object: any)
+ }
}
\ No newline at end of file
diff --git a/test/typings/json8.d.ts b/test/typings/json8.d.ts
deleted file mode 100644
index 458fca7c29d..00000000000
--- a/test/typings/json8.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-declare module "json8" {
- export function equal(a: any, b: any): boolean
- export function serialize(value: any, options?: any): string
-}
\ No newline at end of file
diff --git a/yarn.lock b/yarn.lock
index 6add60d79a2..baaa46e2dae 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -48,9 +48,9 @@
dependencies:
conventional-changelog "0.0.17"
-"@types/electron@^1.4.29":
- version "1.4.29"
- resolved "https://registry.yarnpkg.com/@types/electron/-/electron-1.4.29.tgz#f4555c669799f3b208e7de1770e3f4cbf9e9f0a2"
+"@types/electron@^1.4.30":
+ version "1.4.30"
+ resolved "https://registry.yarnpkg.com/@types/electron/-/electron-1.4.30.tgz#d79b1bc117b6cfa770220d6aeb5a475659cd7961"
dependencies:
"@types/node" "*"
@@ -58,13 +58,13 @@
version "1.3.29"
resolved "https://registry.yarnpkg.com/@types/ini/-/ini-1.3.29.tgz#1325e981e047d40d13ce0359b821475b97741d2f"
-"@types/jest@^16.0.1":
- version "16.0.1"
- resolved "https://registry.yarnpkg.com/@types/jest/-/jest-16.0.1.tgz#c7820ab2bedefe121d0e5ffaa8d0b22f44793f24"
+"@types/jest@^16.0.2":
+ version "16.0.2"
+ resolved "https://registry.yarnpkg.com/@types/jest/-/jest-16.0.2.tgz#77dd322d5c59119ccc41480c57b98e4f735c1c01"
-"@types/js-yaml@^3.5.28":
- version "3.5.28"
- resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.5.28.tgz#efd7614f8eb1b924c41235ff653b7370da467fac"
+"@types/js-yaml@^3.5.29":
+ version "3.5.29"
+ resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.5.29.tgz#29f4dd9314fbccb080d8bd84b9c23811ec5090c2"
"@types/node@*":
version "6.0.52"
@@ -1019,9 +1019,9 @@ dateformat@^1.0.11, dateformat@^1.0.12:
get-stdin "^4.0.1"
meow "^3.3.0"
-debug@2, debug@2.4.5, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.3.2, debug@^2.3.3:
- version "2.4.5"
- resolved "https://registry.yarnpkg.com/debug/-/debug-2.4.5.tgz#34c7b12a1ca96674428f41fe92c49b4ce7cd0607"
+debug@2, debug@2.5.1, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.3.2, debug@^2.3.3:
+ version "2.5.1"
+ resolved "https://registry.yarnpkg.com/debug/-/debug-2.5.1.tgz#9107bb4a506052ec2a02314bc606313ed2b921c1"
dependencies:
ms "0.7.2"
@@ -1105,7 +1105,7 @@ dezalgo@^1.0.0, dezalgo@^1.0.1:
asap "^2.0.0"
wrappy "1"
-diff@^3.0.0, diff@^3.0.1, diff@^3.1.0:
+diff@^3.0.0, diff@^3.0.1:
version "3.1.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.1.0.tgz#9406c73a401e6c2b3ba901c5e2c44eb6a60c5385"
@@ -2144,10 +2144,6 @@ json5@^0.5.0:
version "0.5.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
-json8@^0.9.2:
- version "0.9.2"
- resolved "https://registry.yarnpkg.com/json8/-/json8-0.9.2.tgz#dced62a24c8ed457702d45c71068081925c3011f"
-
jsonfile@^2.1.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"