question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

One of the dependencies is resolved as undefined in test environment (ng test)

See original GitHub issue

Bug Report or Feature Request (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request

Versions.

sharikovvlad:ng2-diary-book svlad$ ng --version
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.3.0
node: 8.3.0
os: darwin x64
@angular/animations: 4.3.5
@angular/cdk: 2.0.0-beta.8
@angular/common: 4.3.5
@angular/compiler: 4.3.5
@angular/core: 4.3.5
@angular/forms: 4.3.5
@angular/http: 4.3.5
@angular/material: 2.0.0-beta.8
@angular/platform-browser: 4.3.5
@angular/platform-browser-dynamic: 4.3.5
@angular/router: 4.3.5
@angular/cli: 1.3.0
@angular/compiler-cli: 4.3.5
@angular/language-service: 4.3.5
sharikovvlad:ng2-diary-book svlad$

Repro steps.

  1. git clone git@github.com:sharikovvladislav/ng2-diary-book.git
  2. git checkout repro
  3. git fetch
  4. yarn install
  5. yarn test:repro

The log given by the failure.

You will get:

LOG: 'markdown in MarkdownPipe', undefined
Chrome 60.0.3112 (Mac OS X 10.12.6): Executed 0 of 3 SUCCESS (0 secs / 0 secs)
Chrome 60.0.3112 (Mac OS X 10.12.6) MyDairyPageComponent  FAILED
        TypeError: Cannot read property 'makeHtml' of undefined
            at MarkdownPipe.transform (webpack:////Users/svlad/dev/ng2-diary-book/src/app/shared/pipes/markdown.ts?:17:37)
            at checkAndUpdatePureExpressionInline (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:11848:38)
            at checkAndUpdateNodeInline (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:12549:17)
            at checkAndUpdateNode (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:12482:16)
            at debugCheckAndUpdateNode (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:13343:59)
            at debugCheckRenderNodeFn (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:13322:13)
            at Object.eval [as updateRenderer] (ng:///CoreModule/EntryListItemComponent.ngfactory.js:66:52)
            at Object.debugUpdateRenderer [as updateRenderer] (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:13307:21)
            at checkAndUpdateView (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:12454:14)
            at callViewAction (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:12814:21)
Chrome 60.0.3112 (Mac OS X 10.12.6): Executed 1 of 3 (1 FAILED) (0 secs / 1.071 secs)
Chrome 60.0.3112 (Mac OS X 10.12.6) MyDairyPageComponent  FAILED
        TypeError: Cannot read property 'makeHtml' of undefined
            at MarkdownPipe.transform (webpack:////Users/svlad/dev/ng2-diary-book/src/app/shared/pipes/markdown.ts?:17:37)
            at checkAndUpdatePureExpressionInline (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:11848:38)
            at checkAndUpdateNodeInline (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:12549:17)
            at checkAndUpdateNode (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:12482:16)
            at debugCheckAndUpdateNode (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:13343:59)
            at debugCheckRenderNodeFn (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:13322:13)
            at Object.eval [as updateRenderer] (ng:///CoreModule/EntryListItemComponent.ngfactory.js:66:52)
            at Object.debugUpdateRenderer [as updateRenderer] (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:13307:21)
            at checkAndUpdateView (webpack:////Users/svlad/dev/ng2-diary-book/node_modules/@angular/core/@angular/core.es5.js?:12454:14)
Chrome 60.0.3112 (Mac OS X 10.12.6): Executed 1 of 3 (1 FAILED) (skipped 2) ERROR (1.094 secs / 1.071 secs)
error Command failed with exit code 1.
sharikovvlad:ng2-diary-book svlad$ 

This problem exists only in test environment. If you run ng serve and open localhost:4200 you will see markdown is working fine: you will see <p><em>abc</em></p> on the page and also you will see something like this in the console.

Of course I have markdown-js in the node_modules.

Desired functionality.

Import must work in any environment.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
sharikovvladislavcommented, Aug 31, 2017

import * as markdown from 'markdown-js'; fixed the problem.

Thank you very much! Closing this one. Thank you that you pointed me to article which explain that. Sry for the time 😦

0reactions
angular-automatic-lock-bot[bot]commented, Sep 7, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ng test fails with an "Cannot read property 'options' of ... - GitHub
When running ng test , I get a "Cannot read property 'options' of undefined" error. Expected behavior. I want to be able to...
Read more >
Angular 6 Unit Tests: An error was thrown in afterAll ...
So to resolve this I put all the setup into one, synchronous beforeEach. beforeEach(() => { TestBed.configureTestingModule({ declarations: [ ...
Read more >
Testing Components depending on Services - Testing Angular
Angular's dependency injection maintains only one app-wide instance of the Service, a so-called singleton. Therefore, multiple instances of ...
Read more >
Angular unit testing tutorial with examples - LogRocket Blog
This tutorial demonstrates how to build an Angular app and write a unit test, test an async operator, and automatically generate a unit ......
Read more >
Ahead-of-time (AOT) compilation - Angular
When you run the ng build (build only) or ng serve (build and serve locally) ... 1, code analysis, In this phase, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found