Git Product home page Git Product logo

Comments (10)

brandonroberts avatar brandonroberts commented on June 9, 2024 1

Hey @brandonroberts,

I know this issue is closed but I can't get the tests working. Still the same problem. Should I open a new Issue?

Sure, if you could add an example that would be great

from analog.

vneogi199 avatar vneogi199 commented on June 9, 2024

Looks like it works after adding this import to the test file:
import {describe, beforeEach, it, expect} from 'vitest';.

I'm assuming these are currently defaulting to @nx/jest used by @nx/angular plugin instead of the vitest ones.

from analog.

brandonroberts avatar brandonroberts commented on June 9, 2024

Its probably an issue with using the globals. Importing them directly should work fine in most cases

from analog.

jahusa02 avatar jahusa02 commented on June 9, 2024

Also when I import it or describe because I want to use it.each, fakeAsync doesn't work anymore (ProxyZone Error)

from analog.

lukasz-wroblewski avatar lukasz-wroblewski commented on June 9, 2024

as @jahusa02 said
direct importing causes
Error: Expected to be running in 'ProxyZone', but it was not found.

from analog.

brandonroberts avatar brandonroberts commented on June 9, 2024

as @jahusa02 said direct importing causes Error: Expected to be running in 'ProxyZone', but it was not found.

Yes, that's correct. You have to use the global functions that are patched correctly to operate inside the Zone.js/ProxyZone context

from analog.

jahusa02 avatar jahusa02 commented on June 9, 2024

as @jahusa02 said direct importing causes Error: Expected to be running in 'ProxyZone', but it was not found.

Yes, that's correct. You have to use the global functions that are patched correctly to operate inside the Zone.js/ProxyZone context

But what if I want to use it.each together with fakeAsync?

from analog.

brandonroberts avatar brandonroberts commented on June 9, 2024

@jahusa02 that should work. You can find the patched methods there

https://github.com/analogjs/analog/blob/beta/packages/vite-plugin-angular/setup-vitest.ts#L251

from analog.

jahusa02 avatar jahusa02 commented on June 9, 2024

@brandonroberts I have a spec file where I have fakeAsync and "normal" tests.

When I use the patched function (e.g. not importing it via import { it } from 'vitest'), the it.each tests will fail, but the fakeAsync not.

TypeError: Cannot read properties of undefined (reading 'withContext')
  ../../../packages/vite-plugin-angular/setup-vitest.ts:247:31
  src/lib/+state/effects/add-pending-contract/add-pending-contract.effects.spec.ts:98:6
     96|       { formStateValid: false, contractId: 'foo', satznummer: null },
     97|       { formStateValid: false, contractId: null, satznummer: 'bar' },
     98|     ])(
       |      ^
     99|       'should not post form values if ContractIds are %j',
    100|       ({ formStateValid, contractId, satznummer }) => {
  _ZoneDelegate.invoke ../../../node_modules/zone.js/fesm2015/zone.js:365:28
  ZoneImpl.run ../../../node_modules/zone.js/fesm2015/zone.js:111:43
  ../../../packages/vite-plugin-angular/setup-vitest.ts:41:21

When I importing it, the fakeAsync tests will fail with the mentioned Error: Expected to be running in 'ProxyZone', but it was not found., but the it.each will pass.

I can't give you a test repo at the moment, but maybe this is enough information for you

from analog.

jahusa02 avatar jahusa02 commented on June 9, 2024

Hey @brandonroberts,

I know this issue is closed but I can't get the tests working. Still the same problem. Should I open a new Issue?

from analog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.