We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I've created a chart.js plugin that I now want to test. I'm running this as documented I get the following error:
TypeError: Cannot read property 'test' of undefined
Here is my test:
let canvas: any; beforeEach( () => { canvas = document.createElement('canvas'); canvas.setAttribute('width', '100'); canvas.setAttribute('height', '100'); }); describe( 'plugin', () => { it('renders canvas', () => { plugins.plugin.beforeDatasetDraw( { config: { type: 'doughnut' }, outerRadius: 100, innerRadius: 80, chartArea: { right: 100, bottom: 100 }, ctx: canvas.getContext('2d') }); expect( canvas ).toMatchSnapshot(); }); });
The plugin I'm testing:
const plugin = { id: 'plugin', beforeDatasetDraw: (chart: any) => { if (chart.config.type === 'doughnut') { const ctx = chart.ctx; ctx.beginPath(); ctx.strokeStyle = '#D2D2D2'; ctx.arc( chart.chartArea.right / 2, chart.chartArea.bottom / 2, (chart.outerRadius + chart.innerRadius) / 2, 0, 2 * Math.PI ); ctx.stroke(); } } };
The text was updated successfully, but these errors were encountered:
The README is a bit wrong here.
If not using TypeScript, Babel will allow this (even though there is no default export).
import canvasSerializer from 'jest-canvas-snapshot-serializer';
TypeScript requires you to do it properly:
import * as canvasSerializer from 'jest-canvas-snapshot-serializer';
Sorry, something went wrong.
No branches or pull requests
I've created a chart.js plugin that I now want to test. I'm running this as documented I get the following error:
TypeError: Cannot read property 'test' of undefined
Here is my test:
The plugin I'm testing:
The text was updated successfully, but these errors were encountered: