Jest Testing - TypeError: d is not a function
I'm trying to add testing to my Electron + Vue2 application written in TypeScript using ts-Jest/ Jest and Chai. I've gotten previous issues fixed like import not being recognized and others. Currently I'm running into an issue where when I try running my simple test I'm seeing: (look in output for more context)
TypeError: d is not a function
This however is far less descriptive than previously, I'm also not sure quite what it's pointing to as it seems to be related to this issue which was fixed when I updated this module.
Of course this isn't an issue when I'm actually running my application and I'm having trouble finding anything related to this even with my increasing amount of sleuthing regarding Jest and the like from my previous posts.
Output
$ npm run test
> app@1.0.0 test C:UsersdanielDesktopappapp
> jest --debug --detectOpenHandles --forceExit --verbose --colors
{
"configs": [
{
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "C:\Users\daniel\AppData\Local\Temp\jest",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"\\node_modules\\"
],
"detectLeaks": false,
"detectOpenHandles": true,
"errorOnDeprecated": false,
"filter": null,
"forceCoverageMatch": ,
"globals": {
"ts-jest": {
"tsConfig": "./src/app/tsconfig.json"
},
"NODE_ENV": "test"
},
"haste": {
"providesModuleNodeModules":
},
"moduleDirectories": [
"node_modules",
"src"
],
"moduleFileExtensions": [
"js",
"ts",
"json",
"node",
"html"
],
"moduleNameMapper": {},
"modulePathIgnorePatterns": ,
"modulePaths": [
"C:\Users\daniel\Desktop\app\app\src",
"C:\Users\daniel\Desktop\app\app\node_modules"
],
"name": "49c9f95751e84975b9ee85f166b8dbdd",
"prettierPath": "C:\Users\daniel\Desktop\app\app\node_modules\prettier\index.js",
"resetMocks": false,
"resetModules": false,
"resolver": null,
"restoreMocks": false,
"rootDir": "C:\Users\daniel\Desktop\app\app",
"roots": [
"C:\Users\daniel\Desktop\app\app"
],
"runner": "jest-runner",
"setupFiles": ,
"setupTestFrameworkScriptFile": null,
"skipFilter": false,
"snapshotSerializers": ,
"testEnvironment": "C:\Users\daniel\Desktop\app\app\node_modules\jest-environment-node\build\index.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [
"**/__tests__/**/*.js?(x)",
"**/?(*.)+(spec|test).js?(x)",
"**/__tests__/**/*.ts?(x)",
"**/?(*.)+(spec|test).ts?(x)"
],
"testPathIgnorePatterns": [
"\\build\\",
"\\config\\",
"\\data\\",
"\\dist\\",
"\\node_modules\\",
"\\test\\",
"\\vendor\\"
],
"testRegex": "",
"testRunner": "C:\Users\daniel\Desktop\app\app\node_modules\jest-jasmine2\build\index.js",
"testURL": "http://localhost",
"timers": "real",
"transform": [
[
"^.+\.html$",
"C:\Users\daniel\Desktop\app\app\config\htmlLoader.js"
],
[
"^.+\.[tj]sx?$",
"C:\Users\daniel\Desktop\app\app\node_modules\ts-jest\dist\index.js"
]
],
"transformIgnorePatterns": [
"node_modules\\(?!(bootstrap-vue)\\)"
],
"watchPathIgnorePatterns":
}
],
"globalConfig": {
"bail": false,
"changedFilesWithAncestor": false,
"collectCoverage": false,
"collectCoverageFrom": null,
"coverageDirectory": "C:\Users\daniel\Desktop\app\app\coverage",
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"coverageThreshold": null,
"detectLeaks": false,
"detectOpenHandles": true,
"errorOnDeprecated": false,
"expand": false,
"filter": null,
"forceExit": true,
"globalSetup": null,
"globalTeardown": null,
"listTests": false,
"maxWorkers": 3,
"noStackTrace": false,
"nonFlagArgs": ,
"notify": false,
"notifyMode": "always",
"passWithNoTests": false,
"projects": null,
"rootDir": "C:\Users\daniel\Desktop\app\app",
"runTestsByPath": false,
"skipFilter": false,
"testFailureExitCode": 1,
"testPathPattern": "",
"testResultsProcessor": null,
"updateSnapshot": "new",
"useStderr": false,
"verbose": true,
"watch": false,
"watchman": true
},
"version": "23.6.0"
}
FAIL src/app/tests/app-window.component.spec.ts
● Test suite failed to run
TypeError: d is not a function
3 | import { Prop } from 'vue-property-decorator'
4 | import {
> 5 | ipcMainToRendererAppChannel,
| ^
6 | IpcMainToRendererAppMessage
7 | } from '../../../contracts/appAppMessages'
8 | import {
at Object.<anonymous>.__decorate (src/app/features/webview/webview.component.ts:5:95)
at Object.<anonymous> (src/app/features/webview/webview.component.ts:23:30)
at Object.<anonymous> (src/app/features/app-application-content/app-application-content.component.ts:24:1)
at Object.<anonymous> (src/app/features/app-content/app-content.component.ts:9:1)
console.log src/shared/Log.ts:4
not able to resolve rtc url ReferenceError: fetch is not defined
at Object.getJson (C:UsersdanielDesktopappappsrcsharedProtocolRequests.ts:28:5)
at Function.getappConfig (C:UsersdanielDesktopappappsrcsharedConfig.protocol.ts:27:35)
at Object.getConfig (C:UsersdanielDesktopappappsrcrendererconfig.ts:7:57)
at discoverRTCUrl (C:UsersdanielDesktopappappsrcrendererrtc.ts:7:35)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcrendererrtc.ts:10:49)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
at Runtime.requireModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:376:14)
at Runtime.requireModuleOrMock (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:463:19)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcappfeaturesapp-application-contentapp-application-content.component.ts:15:1)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 3.218s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app@1.0.0 test: `jest --debug --detectOpenHandles --forceExit --verbose --colors`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersdanielAppDataRoamingnpm-cache_logs2018-11-23T15_31_12_028Z-debug.log
jest.config.js
module.exports = {
preset: 'ts-jest/presets/js-with-ts',
testEnvironment: 'node',
verbose: true,
moduleDirectories: ['node_modules', 'src'],
modulePaths: ['<rootDir>/src', '<rootDir>/node_modules'],
moduleFileExtensions: ['js', 'ts', 'json', 'node', 'html'],
transform: {
'^.+\.html$': '<rootDir>/config/htmlLoader.js'
},
transformIgnorePatterns: ['node_modules/(?!(bootstrap-vue)/)'],
testPathIgnorePatterns: [
'/build/',
'/config/',
'/data/',
'/dist/',
'/node_modules/',
'/test/',
'/vendor/'
],
globals: {
'ts-jest': {
tsConfig: './src/app/tsconfig.json'
},
NODE_ENV: 'test'
}
}
tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"outDir": "./built/",
"sourceMap": true,
"strict": true,
"moduleResolution": "node",
"target": "ES2017",
"experimentalDecorators": true,
"noEmitHelpers": false,
"noImplicitAny": false,
"emitDecoratorMetadata": true,
"allowSyntheticDefaultImports": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"esModuleInterop": true,
"lib": ["es2017", "dom"],
"include": [
"**/*",
"../types/**/*",
"../../node_modules/bootstrap-vue/**/*",
"../../node_modules/electron/**/*"
]
}
}
the test
import { expect } from 'chai'
import 'jest'
import { appWindowComponent } from './app-window.component'
const appWindowComponent = new appWindowComponent()
describe('Test: Set Title Function', () => {
it('should set the variable title to the passed variable', () => {
const title = 'this is a test'
appWindowComponent.setTitle(title)
expect(appWindowComponent.title).to.equal(title)
})
})
Edit #1
After doing some more I spaced out imports to see if jest was giving me incorrect pointer and it was:
FAIL src/app/tests/app-window.component.spec.ts
● Test suite failed to run
TypeError: d is not a function
3 | import Component from 'vue-class-component'
4 |
> 5 | import { Prop } from 'vue-property-decorator'
| ^
6 |
7 | import { ipcMainToRendererAppChannel,
8 | IpcMainToRendererAppMessage
at Object.<anonymous>.__decorate (src/app/features/webview/webview.component.ts:5:95)
at Object.<anonymous> (src/app/features/webview/webview.component.ts:25:30)
at Object.<anonymous> (src/app/features/app-application-content/app-application-content.component.ts:24:1)
at Object.<anonymous> (src/app/features/app-content/app-content.component.ts:9:1)
Edit #2
using Jest-Fetch-Mock I got rid of
console.log src/shared/Log.ts:4
not able to resolve rtc url ReferenceError: fetch is not defined
at Object.getJson (C:UsersdanielDesktopappappsrcsharedProtocolRequests.ts:28:5)
at Function.getappConfig (C:UsersdanielDesktopappappsrcsharedConfig.protocol.ts:27:35)
at Object.getConfig (C:UsersdanielDesktopappappsrcrendererconfig.ts:7:57)
at discoverRTCUrl (C:UsersdanielDesktopappappsrcrendererrtc.ts:7:35)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcrendererrtc.ts:10:49)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
at Runtime.requireModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:376:14)
at Runtime.requireModuleOrMock (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:463:19)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcappfeaturesapp-application-contentapp-application-content.component.ts:15:1)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
typescript vue.js automated-tests jestjs chai
add a comment |
I'm trying to add testing to my Electron + Vue2 application written in TypeScript using ts-Jest/ Jest and Chai. I've gotten previous issues fixed like import not being recognized and others. Currently I'm running into an issue where when I try running my simple test I'm seeing: (look in output for more context)
TypeError: d is not a function
This however is far less descriptive than previously, I'm also not sure quite what it's pointing to as it seems to be related to this issue which was fixed when I updated this module.
Of course this isn't an issue when I'm actually running my application and I'm having trouble finding anything related to this even with my increasing amount of sleuthing regarding Jest and the like from my previous posts.
Output
$ npm run test
> app@1.0.0 test C:UsersdanielDesktopappapp
> jest --debug --detectOpenHandles --forceExit --verbose --colors
{
"configs": [
{
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "C:\Users\daniel\AppData\Local\Temp\jest",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"\\node_modules\\"
],
"detectLeaks": false,
"detectOpenHandles": true,
"errorOnDeprecated": false,
"filter": null,
"forceCoverageMatch": ,
"globals": {
"ts-jest": {
"tsConfig": "./src/app/tsconfig.json"
},
"NODE_ENV": "test"
},
"haste": {
"providesModuleNodeModules":
},
"moduleDirectories": [
"node_modules",
"src"
],
"moduleFileExtensions": [
"js",
"ts",
"json",
"node",
"html"
],
"moduleNameMapper": {},
"modulePathIgnorePatterns": ,
"modulePaths": [
"C:\Users\daniel\Desktop\app\app\src",
"C:\Users\daniel\Desktop\app\app\node_modules"
],
"name": "49c9f95751e84975b9ee85f166b8dbdd",
"prettierPath": "C:\Users\daniel\Desktop\app\app\node_modules\prettier\index.js",
"resetMocks": false,
"resetModules": false,
"resolver": null,
"restoreMocks": false,
"rootDir": "C:\Users\daniel\Desktop\app\app",
"roots": [
"C:\Users\daniel\Desktop\app\app"
],
"runner": "jest-runner",
"setupFiles": ,
"setupTestFrameworkScriptFile": null,
"skipFilter": false,
"snapshotSerializers": ,
"testEnvironment": "C:\Users\daniel\Desktop\app\app\node_modules\jest-environment-node\build\index.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [
"**/__tests__/**/*.js?(x)",
"**/?(*.)+(spec|test).js?(x)",
"**/__tests__/**/*.ts?(x)",
"**/?(*.)+(spec|test).ts?(x)"
],
"testPathIgnorePatterns": [
"\\build\\",
"\\config\\",
"\\data\\",
"\\dist\\",
"\\node_modules\\",
"\\test\\",
"\\vendor\\"
],
"testRegex": "",
"testRunner": "C:\Users\daniel\Desktop\app\app\node_modules\jest-jasmine2\build\index.js",
"testURL": "http://localhost",
"timers": "real",
"transform": [
[
"^.+\.html$",
"C:\Users\daniel\Desktop\app\app\config\htmlLoader.js"
],
[
"^.+\.[tj]sx?$",
"C:\Users\daniel\Desktop\app\app\node_modules\ts-jest\dist\index.js"
]
],
"transformIgnorePatterns": [
"node_modules\\(?!(bootstrap-vue)\\)"
],
"watchPathIgnorePatterns":
}
],
"globalConfig": {
"bail": false,
"changedFilesWithAncestor": false,
"collectCoverage": false,
"collectCoverageFrom": null,
"coverageDirectory": "C:\Users\daniel\Desktop\app\app\coverage",
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"coverageThreshold": null,
"detectLeaks": false,
"detectOpenHandles": true,
"errorOnDeprecated": false,
"expand": false,
"filter": null,
"forceExit": true,
"globalSetup": null,
"globalTeardown": null,
"listTests": false,
"maxWorkers": 3,
"noStackTrace": false,
"nonFlagArgs": ,
"notify": false,
"notifyMode": "always",
"passWithNoTests": false,
"projects": null,
"rootDir": "C:\Users\daniel\Desktop\app\app",
"runTestsByPath": false,
"skipFilter": false,
"testFailureExitCode": 1,
"testPathPattern": "",
"testResultsProcessor": null,
"updateSnapshot": "new",
"useStderr": false,
"verbose": true,
"watch": false,
"watchman": true
},
"version": "23.6.0"
}
FAIL src/app/tests/app-window.component.spec.ts
● Test suite failed to run
TypeError: d is not a function
3 | import { Prop } from 'vue-property-decorator'
4 | import {
> 5 | ipcMainToRendererAppChannel,
| ^
6 | IpcMainToRendererAppMessage
7 | } from '../../../contracts/appAppMessages'
8 | import {
at Object.<anonymous>.__decorate (src/app/features/webview/webview.component.ts:5:95)
at Object.<anonymous> (src/app/features/webview/webview.component.ts:23:30)
at Object.<anonymous> (src/app/features/app-application-content/app-application-content.component.ts:24:1)
at Object.<anonymous> (src/app/features/app-content/app-content.component.ts:9:1)
console.log src/shared/Log.ts:4
not able to resolve rtc url ReferenceError: fetch is not defined
at Object.getJson (C:UsersdanielDesktopappappsrcsharedProtocolRequests.ts:28:5)
at Function.getappConfig (C:UsersdanielDesktopappappsrcsharedConfig.protocol.ts:27:35)
at Object.getConfig (C:UsersdanielDesktopappappsrcrendererconfig.ts:7:57)
at discoverRTCUrl (C:UsersdanielDesktopappappsrcrendererrtc.ts:7:35)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcrendererrtc.ts:10:49)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
at Runtime.requireModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:376:14)
at Runtime.requireModuleOrMock (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:463:19)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcappfeaturesapp-application-contentapp-application-content.component.ts:15:1)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 3.218s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app@1.0.0 test: `jest --debug --detectOpenHandles --forceExit --verbose --colors`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersdanielAppDataRoamingnpm-cache_logs2018-11-23T15_31_12_028Z-debug.log
jest.config.js
module.exports = {
preset: 'ts-jest/presets/js-with-ts',
testEnvironment: 'node',
verbose: true,
moduleDirectories: ['node_modules', 'src'],
modulePaths: ['<rootDir>/src', '<rootDir>/node_modules'],
moduleFileExtensions: ['js', 'ts', 'json', 'node', 'html'],
transform: {
'^.+\.html$': '<rootDir>/config/htmlLoader.js'
},
transformIgnorePatterns: ['node_modules/(?!(bootstrap-vue)/)'],
testPathIgnorePatterns: [
'/build/',
'/config/',
'/data/',
'/dist/',
'/node_modules/',
'/test/',
'/vendor/'
],
globals: {
'ts-jest': {
tsConfig: './src/app/tsconfig.json'
},
NODE_ENV: 'test'
}
}
tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"outDir": "./built/",
"sourceMap": true,
"strict": true,
"moduleResolution": "node",
"target": "ES2017",
"experimentalDecorators": true,
"noEmitHelpers": false,
"noImplicitAny": false,
"emitDecoratorMetadata": true,
"allowSyntheticDefaultImports": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"esModuleInterop": true,
"lib": ["es2017", "dom"],
"include": [
"**/*",
"../types/**/*",
"../../node_modules/bootstrap-vue/**/*",
"../../node_modules/electron/**/*"
]
}
}
the test
import { expect } from 'chai'
import 'jest'
import { appWindowComponent } from './app-window.component'
const appWindowComponent = new appWindowComponent()
describe('Test: Set Title Function', () => {
it('should set the variable title to the passed variable', () => {
const title = 'this is a test'
appWindowComponent.setTitle(title)
expect(appWindowComponent.title).to.equal(title)
})
})
Edit #1
After doing some more I spaced out imports to see if jest was giving me incorrect pointer and it was:
FAIL src/app/tests/app-window.component.spec.ts
● Test suite failed to run
TypeError: d is not a function
3 | import Component from 'vue-class-component'
4 |
> 5 | import { Prop } from 'vue-property-decorator'
| ^
6 |
7 | import { ipcMainToRendererAppChannel,
8 | IpcMainToRendererAppMessage
at Object.<anonymous>.__decorate (src/app/features/webview/webview.component.ts:5:95)
at Object.<anonymous> (src/app/features/webview/webview.component.ts:25:30)
at Object.<anonymous> (src/app/features/app-application-content/app-application-content.component.ts:24:1)
at Object.<anonymous> (src/app/features/app-content/app-content.component.ts:9:1)
Edit #2
using Jest-Fetch-Mock I got rid of
console.log src/shared/Log.ts:4
not able to resolve rtc url ReferenceError: fetch is not defined
at Object.getJson (C:UsersdanielDesktopappappsrcsharedProtocolRequests.ts:28:5)
at Function.getappConfig (C:UsersdanielDesktopappappsrcsharedConfig.protocol.ts:27:35)
at Object.getConfig (C:UsersdanielDesktopappappsrcrendererconfig.ts:7:57)
at discoverRTCUrl (C:UsersdanielDesktopappappsrcrendererrtc.ts:7:35)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcrendererrtc.ts:10:49)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
at Runtime.requireModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:376:14)
at Runtime.requireModuleOrMock (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:463:19)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcappfeaturesapp-application-contentapp-application-content.component.ts:15:1)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
typescript vue.js automated-tests jestjs chai
add a comment |
I'm trying to add testing to my Electron + Vue2 application written in TypeScript using ts-Jest/ Jest and Chai. I've gotten previous issues fixed like import not being recognized and others. Currently I'm running into an issue where when I try running my simple test I'm seeing: (look in output for more context)
TypeError: d is not a function
This however is far less descriptive than previously, I'm also not sure quite what it's pointing to as it seems to be related to this issue which was fixed when I updated this module.
Of course this isn't an issue when I'm actually running my application and I'm having trouble finding anything related to this even with my increasing amount of sleuthing regarding Jest and the like from my previous posts.
Output
$ npm run test
> app@1.0.0 test C:UsersdanielDesktopappapp
> jest --debug --detectOpenHandles --forceExit --verbose --colors
{
"configs": [
{
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "C:\Users\daniel\AppData\Local\Temp\jest",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"\\node_modules\\"
],
"detectLeaks": false,
"detectOpenHandles": true,
"errorOnDeprecated": false,
"filter": null,
"forceCoverageMatch": ,
"globals": {
"ts-jest": {
"tsConfig": "./src/app/tsconfig.json"
},
"NODE_ENV": "test"
},
"haste": {
"providesModuleNodeModules":
},
"moduleDirectories": [
"node_modules",
"src"
],
"moduleFileExtensions": [
"js",
"ts",
"json",
"node",
"html"
],
"moduleNameMapper": {},
"modulePathIgnorePatterns": ,
"modulePaths": [
"C:\Users\daniel\Desktop\app\app\src",
"C:\Users\daniel\Desktop\app\app\node_modules"
],
"name": "49c9f95751e84975b9ee85f166b8dbdd",
"prettierPath": "C:\Users\daniel\Desktop\app\app\node_modules\prettier\index.js",
"resetMocks": false,
"resetModules": false,
"resolver": null,
"restoreMocks": false,
"rootDir": "C:\Users\daniel\Desktop\app\app",
"roots": [
"C:\Users\daniel\Desktop\app\app"
],
"runner": "jest-runner",
"setupFiles": ,
"setupTestFrameworkScriptFile": null,
"skipFilter": false,
"snapshotSerializers": ,
"testEnvironment": "C:\Users\daniel\Desktop\app\app\node_modules\jest-environment-node\build\index.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [
"**/__tests__/**/*.js?(x)",
"**/?(*.)+(spec|test).js?(x)",
"**/__tests__/**/*.ts?(x)",
"**/?(*.)+(spec|test).ts?(x)"
],
"testPathIgnorePatterns": [
"\\build\\",
"\\config\\",
"\\data\\",
"\\dist\\",
"\\node_modules\\",
"\\test\\",
"\\vendor\\"
],
"testRegex": "",
"testRunner": "C:\Users\daniel\Desktop\app\app\node_modules\jest-jasmine2\build\index.js",
"testURL": "http://localhost",
"timers": "real",
"transform": [
[
"^.+\.html$",
"C:\Users\daniel\Desktop\app\app\config\htmlLoader.js"
],
[
"^.+\.[tj]sx?$",
"C:\Users\daniel\Desktop\app\app\node_modules\ts-jest\dist\index.js"
]
],
"transformIgnorePatterns": [
"node_modules\\(?!(bootstrap-vue)\\)"
],
"watchPathIgnorePatterns":
}
],
"globalConfig": {
"bail": false,
"changedFilesWithAncestor": false,
"collectCoverage": false,
"collectCoverageFrom": null,
"coverageDirectory": "C:\Users\daniel\Desktop\app\app\coverage",
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"coverageThreshold": null,
"detectLeaks": false,
"detectOpenHandles": true,
"errorOnDeprecated": false,
"expand": false,
"filter": null,
"forceExit": true,
"globalSetup": null,
"globalTeardown": null,
"listTests": false,
"maxWorkers": 3,
"noStackTrace": false,
"nonFlagArgs": ,
"notify": false,
"notifyMode": "always",
"passWithNoTests": false,
"projects": null,
"rootDir": "C:\Users\daniel\Desktop\app\app",
"runTestsByPath": false,
"skipFilter": false,
"testFailureExitCode": 1,
"testPathPattern": "",
"testResultsProcessor": null,
"updateSnapshot": "new",
"useStderr": false,
"verbose": true,
"watch": false,
"watchman": true
},
"version": "23.6.0"
}
FAIL src/app/tests/app-window.component.spec.ts
● Test suite failed to run
TypeError: d is not a function
3 | import { Prop } from 'vue-property-decorator'
4 | import {
> 5 | ipcMainToRendererAppChannel,
| ^
6 | IpcMainToRendererAppMessage
7 | } from '../../../contracts/appAppMessages'
8 | import {
at Object.<anonymous>.__decorate (src/app/features/webview/webview.component.ts:5:95)
at Object.<anonymous> (src/app/features/webview/webview.component.ts:23:30)
at Object.<anonymous> (src/app/features/app-application-content/app-application-content.component.ts:24:1)
at Object.<anonymous> (src/app/features/app-content/app-content.component.ts:9:1)
console.log src/shared/Log.ts:4
not able to resolve rtc url ReferenceError: fetch is not defined
at Object.getJson (C:UsersdanielDesktopappappsrcsharedProtocolRequests.ts:28:5)
at Function.getappConfig (C:UsersdanielDesktopappappsrcsharedConfig.protocol.ts:27:35)
at Object.getConfig (C:UsersdanielDesktopappappsrcrendererconfig.ts:7:57)
at discoverRTCUrl (C:UsersdanielDesktopappappsrcrendererrtc.ts:7:35)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcrendererrtc.ts:10:49)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
at Runtime.requireModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:376:14)
at Runtime.requireModuleOrMock (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:463:19)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcappfeaturesapp-application-contentapp-application-content.component.ts:15:1)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 3.218s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app@1.0.0 test: `jest --debug --detectOpenHandles --forceExit --verbose --colors`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersdanielAppDataRoamingnpm-cache_logs2018-11-23T15_31_12_028Z-debug.log
jest.config.js
module.exports = {
preset: 'ts-jest/presets/js-with-ts',
testEnvironment: 'node',
verbose: true,
moduleDirectories: ['node_modules', 'src'],
modulePaths: ['<rootDir>/src', '<rootDir>/node_modules'],
moduleFileExtensions: ['js', 'ts', 'json', 'node', 'html'],
transform: {
'^.+\.html$': '<rootDir>/config/htmlLoader.js'
},
transformIgnorePatterns: ['node_modules/(?!(bootstrap-vue)/)'],
testPathIgnorePatterns: [
'/build/',
'/config/',
'/data/',
'/dist/',
'/node_modules/',
'/test/',
'/vendor/'
],
globals: {
'ts-jest': {
tsConfig: './src/app/tsconfig.json'
},
NODE_ENV: 'test'
}
}
tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"outDir": "./built/",
"sourceMap": true,
"strict": true,
"moduleResolution": "node",
"target": "ES2017",
"experimentalDecorators": true,
"noEmitHelpers": false,
"noImplicitAny": false,
"emitDecoratorMetadata": true,
"allowSyntheticDefaultImports": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"esModuleInterop": true,
"lib": ["es2017", "dom"],
"include": [
"**/*",
"../types/**/*",
"../../node_modules/bootstrap-vue/**/*",
"../../node_modules/electron/**/*"
]
}
}
the test
import { expect } from 'chai'
import 'jest'
import { appWindowComponent } from './app-window.component'
const appWindowComponent = new appWindowComponent()
describe('Test: Set Title Function', () => {
it('should set the variable title to the passed variable', () => {
const title = 'this is a test'
appWindowComponent.setTitle(title)
expect(appWindowComponent.title).to.equal(title)
})
})
Edit #1
After doing some more I spaced out imports to see if jest was giving me incorrect pointer and it was:
FAIL src/app/tests/app-window.component.spec.ts
● Test suite failed to run
TypeError: d is not a function
3 | import Component from 'vue-class-component'
4 |
> 5 | import { Prop } from 'vue-property-decorator'
| ^
6 |
7 | import { ipcMainToRendererAppChannel,
8 | IpcMainToRendererAppMessage
at Object.<anonymous>.__decorate (src/app/features/webview/webview.component.ts:5:95)
at Object.<anonymous> (src/app/features/webview/webview.component.ts:25:30)
at Object.<anonymous> (src/app/features/app-application-content/app-application-content.component.ts:24:1)
at Object.<anonymous> (src/app/features/app-content/app-content.component.ts:9:1)
Edit #2
using Jest-Fetch-Mock I got rid of
console.log src/shared/Log.ts:4
not able to resolve rtc url ReferenceError: fetch is not defined
at Object.getJson (C:UsersdanielDesktopappappsrcsharedProtocolRequests.ts:28:5)
at Function.getappConfig (C:UsersdanielDesktopappappsrcsharedConfig.protocol.ts:27:35)
at Object.getConfig (C:UsersdanielDesktopappappsrcrendererconfig.ts:7:57)
at discoverRTCUrl (C:UsersdanielDesktopappappsrcrendererrtc.ts:7:35)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcrendererrtc.ts:10:49)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
at Runtime.requireModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:376:14)
at Runtime.requireModuleOrMock (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:463:19)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcappfeaturesapp-application-contentapp-application-content.component.ts:15:1)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
typescript vue.js automated-tests jestjs chai
I'm trying to add testing to my Electron + Vue2 application written in TypeScript using ts-Jest/ Jest and Chai. I've gotten previous issues fixed like import not being recognized and others. Currently I'm running into an issue where when I try running my simple test I'm seeing: (look in output for more context)
TypeError: d is not a function
This however is far less descriptive than previously, I'm also not sure quite what it's pointing to as it seems to be related to this issue which was fixed when I updated this module.
Of course this isn't an issue when I'm actually running my application and I'm having trouble finding anything related to this even with my increasing amount of sleuthing regarding Jest and the like from my previous posts.
Output
$ npm run test
> app@1.0.0 test C:UsersdanielDesktopappapp
> jest --debug --detectOpenHandles --forceExit --verbose --colors
{
"configs": [
{
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "C:\Users\daniel\AppData\Local\Temp\jest",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"\\node_modules\\"
],
"detectLeaks": false,
"detectOpenHandles": true,
"errorOnDeprecated": false,
"filter": null,
"forceCoverageMatch": ,
"globals": {
"ts-jest": {
"tsConfig": "./src/app/tsconfig.json"
},
"NODE_ENV": "test"
},
"haste": {
"providesModuleNodeModules":
},
"moduleDirectories": [
"node_modules",
"src"
],
"moduleFileExtensions": [
"js",
"ts",
"json",
"node",
"html"
],
"moduleNameMapper": {},
"modulePathIgnorePatterns": ,
"modulePaths": [
"C:\Users\daniel\Desktop\app\app\src",
"C:\Users\daniel\Desktop\app\app\node_modules"
],
"name": "49c9f95751e84975b9ee85f166b8dbdd",
"prettierPath": "C:\Users\daniel\Desktop\app\app\node_modules\prettier\index.js",
"resetMocks": false,
"resetModules": false,
"resolver": null,
"restoreMocks": false,
"rootDir": "C:\Users\daniel\Desktop\app\app",
"roots": [
"C:\Users\daniel\Desktop\app\app"
],
"runner": "jest-runner",
"setupFiles": ,
"setupTestFrameworkScriptFile": null,
"skipFilter": false,
"snapshotSerializers": ,
"testEnvironment": "C:\Users\daniel\Desktop\app\app\node_modules\jest-environment-node\build\index.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [
"**/__tests__/**/*.js?(x)",
"**/?(*.)+(spec|test).js?(x)",
"**/__tests__/**/*.ts?(x)",
"**/?(*.)+(spec|test).ts?(x)"
],
"testPathIgnorePatterns": [
"\\build\\",
"\\config\\",
"\\data\\",
"\\dist\\",
"\\node_modules\\",
"\\test\\",
"\\vendor\\"
],
"testRegex": "",
"testRunner": "C:\Users\daniel\Desktop\app\app\node_modules\jest-jasmine2\build\index.js",
"testURL": "http://localhost",
"timers": "real",
"transform": [
[
"^.+\.html$",
"C:\Users\daniel\Desktop\app\app\config\htmlLoader.js"
],
[
"^.+\.[tj]sx?$",
"C:\Users\daniel\Desktop\app\app\node_modules\ts-jest\dist\index.js"
]
],
"transformIgnorePatterns": [
"node_modules\\(?!(bootstrap-vue)\\)"
],
"watchPathIgnorePatterns":
}
],
"globalConfig": {
"bail": false,
"changedFilesWithAncestor": false,
"collectCoverage": false,
"collectCoverageFrom": null,
"coverageDirectory": "C:\Users\daniel\Desktop\app\app\coverage",
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"coverageThreshold": null,
"detectLeaks": false,
"detectOpenHandles": true,
"errorOnDeprecated": false,
"expand": false,
"filter": null,
"forceExit": true,
"globalSetup": null,
"globalTeardown": null,
"listTests": false,
"maxWorkers": 3,
"noStackTrace": false,
"nonFlagArgs": ,
"notify": false,
"notifyMode": "always",
"passWithNoTests": false,
"projects": null,
"rootDir": "C:\Users\daniel\Desktop\app\app",
"runTestsByPath": false,
"skipFilter": false,
"testFailureExitCode": 1,
"testPathPattern": "",
"testResultsProcessor": null,
"updateSnapshot": "new",
"useStderr": false,
"verbose": true,
"watch": false,
"watchman": true
},
"version": "23.6.0"
}
FAIL src/app/tests/app-window.component.spec.ts
● Test suite failed to run
TypeError: d is not a function
3 | import { Prop } from 'vue-property-decorator'
4 | import {
> 5 | ipcMainToRendererAppChannel,
| ^
6 | IpcMainToRendererAppMessage
7 | } from '../../../contracts/appAppMessages'
8 | import {
at Object.<anonymous>.__decorate (src/app/features/webview/webview.component.ts:5:95)
at Object.<anonymous> (src/app/features/webview/webview.component.ts:23:30)
at Object.<anonymous> (src/app/features/app-application-content/app-application-content.component.ts:24:1)
at Object.<anonymous> (src/app/features/app-content/app-content.component.ts:9:1)
console.log src/shared/Log.ts:4
not able to resolve rtc url ReferenceError: fetch is not defined
at Object.getJson (C:UsersdanielDesktopappappsrcsharedProtocolRequests.ts:28:5)
at Function.getappConfig (C:UsersdanielDesktopappappsrcsharedConfig.protocol.ts:27:35)
at Object.getConfig (C:UsersdanielDesktopappappsrcrendererconfig.ts:7:57)
at discoverRTCUrl (C:UsersdanielDesktopappappsrcrendererrtc.ts:7:35)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcrendererrtc.ts:10:49)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
at Runtime.requireModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:376:14)
at Runtime.requireModuleOrMock (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:463:19)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcappfeaturesapp-application-contentapp-application-content.component.ts:15:1)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 3.218s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app@1.0.0 test: `jest --debug --detectOpenHandles --forceExit --verbose --colors`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersdanielAppDataRoamingnpm-cache_logs2018-11-23T15_31_12_028Z-debug.log
jest.config.js
module.exports = {
preset: 'ts-jest/presets/js-with-ts',
testEnvironment: 'node',
verbose: true,
moduleDirectories: ['node_modules', 'src'],
modulePaths: ['<rootDir>/src', '<rootDir>/node_modules'],
moduleFileExtensions: ['js', 'ts', 'json', 'node', 'html'],
transform: {
'^.+\.html$': '<rootDir>/config/htmlLoader.js'
},
transformIgnorePatterns: ['node_modules/(?!(bootstrap-vue)/)'],
testPathIgnorePatterns: [
'/build/',
'/config/',
'/data/',
'/dist/',
'/node_modules/',
'/test/',
'/vendor/'
],
globals: {
'ts-jest': {
tsConfig: './src/app/tsconfig.json'
},
NODE_ENV: 'test'
}
}
tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"outDir": "./built/",
"sourceMap": true,
"strict": true,
"moduleResolution": "node",
"target": "ES2017",
"experimentalDecorators": true,
"noEmitHelpers": false,
"noImplicitAny": false,
"emitDecoratorMetadata": true,
"allowSyntheticDefaultImports": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"esModuleInterop": true,
"lib": ["es2017", "dom"],
"include": [
"**/*",
"../types/**/*",
"../../node_modules/bootstrap-vue/**/*",
"../../node_modules/electron/**/*"
]
}
}
the test
import { expect } from 'chai'
import 'jest'
import { appWindowComponent } from './app-window.component'
const appWindowComponent = new appWindowComponent()
describe('Test: Set Title Function', () => {
it('should set the variable title to the passed variable', () => {
const title = 'this is a test'
appWindowComponent.setTitle(title)
expect(appWindowComponent.title).to.equal(title)
})
})
Edit #1
After doing some more I spaced out imports to see if jest was giving me incorrect pointer and it was:
FAIL src/app/tests/app-window.component.spec.ts
● Test suite failed to run
TypeError: d is not a function
3 | import Component from 'vue-class-component'
4 |
> 5 | import { Prop } from 'vue-property-decorator'
| ^
6 |
7 | import { ipcMainToRendererAppChannel,
8 | IpcMainToRendererAppMessage
at Object.<anonymous>.__decorate (src/app/features/webview/webview.component.ts:5:95)
at Object.<anonymous> (src/app/features/webview/webview.component.ts:25:30)
at Object.<anonymous> (src/app/features/app-application-content/app-application-content.component.ts:24:1)
at Object.<anonymous> (src/app/features/app-content/app-content.component.ts:9:1)
Edit #2
using Jest-Fetch-Mock I got rid of
console.log src/shared/Log.ts:4
not able to resolve rtc url ReferenceError: fetch is not defined
at Object.getJson (C:UsersdanielDesktopappappsrcsharedProtocolRequests.ts:28:5)
at Function.getappConfig (C:UsersdanielDesktopappappsrcsharedConfig.protocol.ts:27:35)
at Object.getConfig (C:UsersdanielDesktopappappsrcrendererconfig.ts:7:57)
at discoverRTCUrl (C:UsersdanielDesktopappappsrcrendererrtc.ts:7:35)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcrendererrtc.ts:10:49)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
at Runtime.requireModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:376:14)
at Runtime.requireModuleOrMock (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:463:19)
at Object.<anonymous> (C:UsersdanielDesktopappappsrcappfeaturesapp-application-contentapp-application-content.component.ts:15:1)
at Runtime._execModule (C:UsersdanielDesktopappappnode_modulesjest-runtimebuildindex.js:694:13)
typescript vue.js automated-tests jestjs chai
typescript vue.js automated-tests jestjs chai
edited Nov 26 '18 at 17:19
asked Nov 23 '18 at 16:43
Daniel Turcich
226319
226319
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450324%2fjest-testing-typeerror-d-is-not-a-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450324%2fjest-testing-typeerror-d-is-not-a-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown