Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple tests for injectables are failing with a TypeError #210

Closed
wescopeland opened this issue Oct 16, 2019 · 2 comments
Closed

Simple tests for injectables are failing with a TypeError #210

wescopeland opened this issue Oct 16, 2019 · 2 comments

Comments

@wescopeland
Copy link

I'm submitting a...

[x] Support request

Current behavior

Getting an error Cannot read property 'getComponentFromError' of null when writing basic tests for injectables (HTTP or otherwise).

Expected behavior

No error should be displayed and the tests should pass.

Minimal reproduction of the problem with instructions

import { SpectatorService, createServiceFactory } from '@ngneat/spectator';
import { Injectable } from '@angular/core';

@Injectable({ providedIn: 'root' })
export class UserService {
  constructor() {}
}

describe('Service: UserService', () => {
  let spectator: SpectatorService<UserService>;
  const createService = createServiceFactory(UserService);

  // Error is thrown here. TypeError: Cannot read property 'getComponentFromError' of null
  beforeEach(() => (spectator = createService()));

  it('exists', () => {
    expect(spectator.service).toBeDefined();
  });
});

Environment

Angular version: 8.2.11 (latest)
Spectator version: 4.4.2
 
For Tooling issues:
- Node version: 12.6.0
- Platform: macOS 10.15

Others:
This is happening in an Nx 8.6 monorepo.
@dirkluijk
Copy link
Collaborator

It seems not to be related to Spectator (it works here).

I think it has something to do with your test setup or with Nx workspaces. Are you using Jest? Maybe check this issue.

@wescopeland
Copy link
Author

wescopeland commented Oct 16, 2019

Yes, we are using Jest :-)
Thank you for pointing me in the right direction!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants