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

Error with unit test #110

Open
dsumac opened this issue Feb 9, 2018 · 2 comments
Open

Error with unit test #110

dsumac opened this issue Feb 9, 2018 · 2 comments

Comments

@dsumac
Copy link

dsumac commented Feb 9, 2018

Hello,

I would like make unit tests and I have this error:

npm run test:ut -- QRCode

> [email protected] test:ut /opt/workspaces/hipigo
> jest -c jest.config.json --verbose "QRCode"

 FAIL  tests/ut/hippodrome/components/QRCode.test.jsx
  ● render › should render QRCode without any text

    TypeError: Cannot set property 'lineWidth' of null
      
      at constructor.reset (node_modules/qrious/dist/qrious.js:427:25)
      at constructor.render (node_modules/qrious/dist/qrious.js:355:14)
      at Object.update (node_modules/qrious/dist/qrious.js:2146:28)
      at new <anonymous> (node_modules/qrious/dist/qrious.js:2085:10)
      at _callee$ (tests/ut/hippodrome/components/QRCode.test.jsx:7:8)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:62:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:296:22)
      at Generator.prototype.(anonymous function) [as next] (node_modules/regenerator-runtime/runtime.js:114:21)
      at step (tests/ut/hippodrome/components/QRCode.test.jsx:3:357)
      at tests/ut/hippodrome/components/QRCode.test.jsx:3:587
          at new Promise (<anonymous>)
      at Object.<anonymous> (tests/ut/hippodrome/components/QRCode.test.jsx:3:268)
          at new Promise (<anonymous>)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
          at <anonymous>

  render
    ✕ should render QRCode without any text (35ms)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        3.671s
Ran all test suites matching "QRCode".
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:ut: `jest -c jest.config.json --verbose "QRCode"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] test:ut 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!     /home/d2i/.npm/_logs/2018-02-09T16_24_09_315Z-debug.log

The test code is very simple:

import { expect } from 'chai';
import QRious from 'qrious';

describe('render', () => {
	it('should render QRCode without any text', async () => {
		const qr = await new QRious({ value: 'test' });

		expect(qr.toDataUrl()).to.be.a('string');
	});
});

It seems there is a problem of testability.

I use mocha + chai to test.

Do you have any idea ?

@rpavlovs
Copy link

Same issue with Jest

@dsumac
Copy link
Author

dsumac commented Mar 1, 2019

Sorry, actually my example was with jest

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

No branches or pull requests

2 participants