-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Pixi explodes on imports in jest #4769
Comments
|
works for me 🙂
|
In case anyone else searches for this, here's a little more info: You have to install the
after that, this shouldn't be an issue. |
you dont need to install the canvas-prebuilt to be honest. Simply create a mock api on your tests setup. Here's mine, with import { JSDOM } from 'jsdom';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });
const exposedProperties = ['window', 'navigator', 'document'];
const { document } = (new JSDOM('', { url: 'https://your-website-mock.com/' })).window;
global.document = document;
global.window = document.defaultView;
global.requestAnimationFrame = (callback) => {
setTimeout(callback, 0);
};
Object.keys(document.defaultView).forEach((property) => {
if (typeof global[property] === 'undefined') {
exposedProperties.push(property);
global[property] = document.defaultView[property];
}
});
global.window.HTMLCanvasElement.prototype.getContext = () => {
return {
fillRect: () => {},
clearRect: () => {},
getImageData: (x, y, w, h) => {
return {
data: new Array(w * h * 4),
};
},
putImageData: () => {},
createImageData: () => {
return [];
},
setTransform: () => {},
drawImage: () => {},
save: () => {},
fillText: () => {},
restore: () => {},
beginPath: () => {},
moveTo: () => {},
lineTo: () => {},
closePath: () => {},
stroke: () => {},
translate: () => {},
scale: () => {},
rotate: () => {},
arc: () => {},
fill: () => {},
measureText: () => {
return {
width: 0,
};
},
transform: () => {},
rect: () => {},
clip: () => {},
};
};
global.window.HTMLCanvasElement.prototype.toDataURL = () => {
return '';
};
global.navigator = {
userAgent: 'node.js',
}; |
nice @andrevenancio 😄 |
For anyone googling, this can also affect |
That's was exactly why I found this issue @sgb-io ! I was trying to use |
I already had If you already have |
This worked for me: |
The @lk-jeffpeck solution works like a charm for me! |
Thanks. Worked for me as well. In case future readers get this problem: See: configuration |
Any solution? |
having the same here... |
Some of |
Nice one! I've got that also from an open issue on lottie-react-web repo |
Hope this helps the next seeker. I was able to get a clean pass on jest after running into this exact issue by following this: Note: does appear |
Tried pixijs/pixijs#4769 after encountering TypeError: Cannot set property 'fillStyle' of null It solved the problem with the game-dev component.
Tried pixijs/pixijs#4769 after encountering TypeError: Cannot set property 'fillStyle' of null It solved the problem with the game-dev component.
Tried pixijs/pixijs#4769 after encountering TypeError: Cannot set property 'fillStyle' of null It solved the problem with the game-dev component.
Tried pixijs/pixijs#4769 after encountering TypeError: Cannot set property 'fillStyle' of null It solved the problem with the game-dev component.
Sorta maybe worked for me too. I added
|
* Refactor constants (#2) - Move ASSETS_HOST to within constants.js - Add a backend directory to facilitate future communication with the backend - Add ability to toggle asset hosts * Setup game state fetcher Includes implementation to manage active stories * Refactor save and load data * Create game testing page * Create telescope/night filter * Add test for Game Dev link * Add override functions * Retrieve data from backend * Add more tests for game-dev page and material page * Deleted unnecessary page * To use test bucket * Changed test page to automatically find folder * Prettified and Updated Snapshots * Change the story retrieval workflow Dev users will first attempt to pull from the test bucket. If it fails, then try the live bucket. Student users will always pull from the live bucket. * Fixed location of stories * Json Upload * Modify test for StoryTable * Read input JSON file and set override * Enable the JSON file to simulate customized mission pointer and current date as well * Fixed bug where tests on PixiJS will fail due to canvas error Tried pixijs/pixijs#4769 after encountering TypeError: Cannot set property 'fillStyle' of null It solved the problem with the game-dev component. * Fully moved completed-quests and collectibles away from localStorage. Saving and loading of quest and collectibles will come through the user data or from overriding data. * Save Manager now saves story action sequence and start location to localStorage * Added new actions and changed state for the addition of game state. - Made new actiontypes to update game state in the backend and in session. - Updated tests to accomodate for game state. * Updated game and gamedev components to accomodate the addition of game state and changes in save manager. * Deleted non-essential mission pointer override * Fixed Typo 'hasColletible'. * Merged GroundControl with gameStateUpdate * Using SessionStorage for Game State instead of JS * Minor Cosmetic Changes * GamePage to load only when all information is gotten * Fixed some errors and allow for reset json files * Updated Game Components to use GroundControl Use Ground Control's assessment overview instead of master.xml file. Less things to keep track of this way. * Updated Material Table Snapshots * Minor bugfixes and documentation - Fixed bug with regards to missing stories, testers now use default story if they have not overriden the game. - Potential bug fixed With no missions available, will return leaving a black screen, instead of crashing. - Fixed bug that stops the game from compiling when the last mission has closed, will now only show last opened mission. - Added minor documentation * Point hosts back to default * Removed console.log function * Fix bugs in backend.ts * Prettify code * Fix bugs in backend.ts Co-authored-by: Asthenosphere <e0271247@u.nus.edu> Co-authored-by: wltan <wltan@users.noreply.github.com> Co-authored-by: travisryte <thuyaoo200@gmail.com> Co-authored-by: jetkan-yk <jetkan.yk@gmail.com>
TypeError: Cannot set property 'fillStyle' of null
The text was updated successfully, but these errors were encountered: