ChrisShank / xstate-vue2

Vue 2 composables for XState.
MIT License
19 stars 5 forks source link

Unit tests seem broken a bit #1

Closed fobdy closed 3 years ago

fobdy commented 3 years ago

Yarn 1.22.10 Node 14.15.4

git clone ...
cd ...
yarn
yarn test

yarn test
yarn run v1.22.10
$ jest
FAIL  test/useInterpret.test.ts
● Test suite failed to run
test/useInterpret.test.ts:1:44 - error TS2307: Cannot find module '@testing-library/vue' or its corresponding type declarations.

1 import { render, fireEvent, waitFor } from '@testing-library/vue';
                                             ~~~~~~~~~~~~~~~~~~~~~~
test/useInterpret.test.ts:4:1 - error TS2593: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

4 describe('useInterpret composable function', () => {
  ~~~~~~~~
test/useInterpret.test.ts:5:3 - error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

5   it('observer should be called with initial state', async () => {
    ~~
test/useInterpret.test.ts:9:25 - error TS2304: Cannot find name 'expect'.

9     await waitFor(() => expect(buttonEl.textContent).toBe('Turn on'));
                          ~~~~~~
test/useInterpret.test.ts:12:3 - error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

12   it('observer should be called with next state', async () => {
     ~~
test/useInterpret.test.ts:17:25 - error TS2304: Cannot find name 'expect'.

17     await waitFor(() => expect(buttonEl.textContent).toBe('Turn on'));
                           ~~~~~~
test/useInterpret.test.ts:19:25 - error TS2304: Cannot find name 'expect'.

19     await waitFor(() => expect(buttonEl.textContent).toBe('Turn off'));
                           ~~~~~~

FAIL test/useFSM.test.ts ● Test suite failed to run

test/useFSM.test.ts:1:44 - error TS2307: Cannot find module '@testing-library/vue' or its corresponding type declarations.

1 import { render, fireEvent, waitFor } from '@testing-library/vue';
                                             ~~~~~~~~~~~~~~~~~~~~~~
test/useFSM.test.ts:4:1 - error TS2593: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

4 describe('UseFSM composable function', () => {
  ~~~~~~~~
test/useFSM.test.ts:5:3 - error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

5   it('should work ', async () => {
    ~~
test/useFSM.test.ts:12:5 - error TS2304: Cannot find name 'expect'.

12     expect(dataEl.textContent).toBe('some data');
       ~~~~~~

FAIL test/useActor.test.ts ● Test suite failed to run

test/useActor.test.ts:1:44 - error TS2307: Cannot find module '@testing-library/vue' or its corresponding type declarations.

1 import { render, fireEvent, waitFor } from '@testing-library/vue';
                                             ~~~~~~~~~~~~~~~~~~~~~~
test/useActor.test.ts:9:1 - error TS2593: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

9 describe('useActor composable function', () => {
  ~~~~~~~~
test/useActor.test.ts:10:3 - error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

10   it('initial invoked actor should be immediately available', async () => {
     ~~
test/useActor.test.ts:16:5 - error TS2304: Cannot find name 'expect'.

16     expect(machineStateEl.textContent).toBe('active');
       ~~~~~~
test/useActor.test.ts:17:5 - error TS2304: Cannot find name 'expect'.

17     expect(actorStateEl.textContent).toBe('active');
       ~~~~~~
test/useActor.test.ts:20:3 - error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

20   it('invoked actor in a standalone component should be able to receive events', async () => {
     ~~
test/useActor.test.ts:53:5 - error TS2304: Cannot find name 'expect'.

53     expect(actorStateEl.textContent).toBe('active');
       ~~~~~~
test/useActor.test.ts:55:25 - error TS2304: Cannot find name 'expect'.

55     await waitFor(() => expect(serviceMachine.state.value).toBe('success'));
                           ~~~~~~
test/useActor.test.ts:58:3 - error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

58   it('actor should provide snapshot value immediately', () => {
     ~~
test/useActor.test.ts:62:5 - error TS2304: Cannot find name 'expect'.

62     expect(stateEl.textContent).toEqual('42');
       ~~~~~~
test/useActor.test.ts:65:3 - error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

65   it('should update snapshot value when actor changes', async () => {
     ~~
test/useActor.test.ts:71:5 - error TS2304: Cannot find name 'expect'.

71     expect(stateEl.textContent).toEqual('42');
       ~~~~~~
test/useActor.test.ts:73:5 - error TS2304: Cannot find name 'expect'.

73     expect(stateEl.textContent).toEqual('100');
       ~~~~~~

FAIL test/useService.test.ts ● Test suite failed to run

test/useService.test.ts:1:44 - error TS2307: Cannot find module '@testing-library/vue' or its corresponding type declarations.

1 import { render, fireEvent, waitFor } from '@testing-library/vue';
                                             ~~~~~~~~~~~~~~~~~~~~~~
test/useService.test.ts:5:1 - error TS2593: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

5 describe('useService composable function', () => {
  ~~~~~~~~
test/useService.test.ts:20:3 - error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

20   it('2 components should share a single service instance', async () => {
     ~~
test/useService.test.ts:40:5 - error TS2304: Cannot find name 'expect'.

40     expect(countEls.length).toBe(2);
       ~~~~~~
test/useService.test.ts:42:23 - error TS7006: Parameter 'countEl' implicitly has an 'any' type.

42     countEls.forEach((countEl) => expect(countEl.textContent).toBe('0'));
                         ~~~~~~~
test/useService.test.ts:42:35 - error TS2304: Cannot find name 'expect'.

42     countEls.forEach((countEl) => expect(countEl.textContent).toBe('0'));
                                     ~~~~~~
test/useService.test.ts:47:7 - error TS2304: Cannot find name 'expect'.

47       expect(countEls.every((el) => el.textContent === '1'));
         ~~~~~~
test/useService.test.ts:47:30 - error TS7006: Parameter 'el' implicitly has an 'any' type.

47       expect(countEls.every((el) => el.textContent === '1'));
                                ~~
test/useService.test.ts:51:3 - error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

51   it('service should be updated when it changes', async () => {
     ~~
test/useService.test.ts:62:5 - error TS2304: Cannot find name 'expect'.

62     expect(countEl.textContent).toBe('0');
       ~~~~~~
test/useService.test.ts:64:5 - error TS2304: Cannot find name 'expect'.

64     expect(countEl.textContent).toBe('1');
       ~~~~~~
test/useService.test.ts:68:25 - error TS2304: Cannot find name 'expect'.

68     await waitFor(() => expect(getByTestId('count').textContent).toBe('0'));
                           ~~~~~~

FAIL test/useMachine.test.ts ● Test suite failed to run

test/useMachine.test.ts:1:44 - error TS2307: Cannot find module '@testing-library/vue' or its corresponding type declarations.

1 import { render, fireEvent, waitFor } from '@testing-library/vue';
                                             ~~~~~~~~~~~~~~~~~~~~~~
test/useMachine.test.ts:6:1 - error TS2593: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

6 describe('useMachine composition function', () => {
  ~~~~~~~~
test/useMachine.test.ts:40:3 - error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

40   it('should work with a component ', async () => {
     ~~
test/useMachine.test.ts:47:5 - error TS2304: Cannot find name 'expect'.

47     expect(dataEl.textContent).toBe('some data');
       ~~~~~~
test/useMachine.test.ts:50:3 - error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

50   it('should work with a component with rehydrated state', async () => {
     ~~
test/useMachine.test.ts:56:5 - error TS2304: Cannot find name 'expect'.

56     expect(dataEl.textContent).toBe('persisted data');
       ~~~~~~
test/useMachine.test.ts:59:3 - error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

59   it('should work with a component with rehydrated state config', async () => {
     ~~
test/useMachine.test.ts:68:5 - error TS2304: Cannot find name 'expect'.

68     expect(dataEl.textContent).toBe('persisted data');
       ~~~~~~
test/useMachine.test.ts:71:3 - error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.

71   it('should not crash without optional `options` parameter being provided', async () => {
     ~~
test/useMachine.test.ts:72:5 - error TS2304: Cannot find name 'expect'.

72     expect(() => {
       ~~~~~~

Test Suites: 5 failed, 5 total Tests: 0 total Snapshots: 0 total Time: 4.696 s Ran all test suites. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.



@ChrisShank Seems some packages are missing
ChrisShank commented 3 years ago

ya I still need to port them over to use Vue 2 testing infra 😅. Should be done by tomorrow, then I will publish to npm!

ChrisShank commented 3 years ago

Fixed in https://github.com/ChrisShank/xstate-vue2/commit/faff52bc7d25aba0fcea4dad702b02b1b325aa2f, publishing package to npm right now.