Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find stylesheet.

See original GitHub issue

This old problem with webkit. Looking at the code I have a question. Why is loop on the document.styleSheets ?


function getColumnCssRules(idx) {
      if (!stylesheet) {
-        var sheets = document.styleSheets;
-        for (var i = 0; i < sheets.length; i++) {
-          if ((sheets[i].ownerNode || sheets[i].owningElement) == $style[0]) {
-            stylesheet = sheets[i];
-            break;
-          }
-        }

        if (!stylesheet) {
          throw new Error("Cannot find stylesheet.");

that if we replace on

function getColumnCssRules(idx) {
      if (!stylesheet) {
 +        stylesheet = $style[0].sheet || $style[0].styleSheet;
        if (!stylesheet) {
          throw new Error("Cannot find stylesheet.");

Thanks in advance!!!

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

ghiscodingcommented, Nov 30, 2022

You’re right in saying that you shouldn’t test the table, you should mock it and you’re not. For my unit tests, I do something like below, the only real thing I use is the Slick Event because I often have to subscribe/notify some events but everything else is and should be mocked.

const dataViewStub = {
  collapseAllGroups: jest.fn(),
  expandAllGroups: jest.fn(),
  setGrouping: jest.fn(),

const getEditorLockMock = {
  commitCurrentEdit: jest.fn(),

const gridStub = {
  getCellNode: jest.fn(),
  getCellFromEvent: jest.fn(),
  getColumns: jest.fn(),
  getHeaderColumn: jest.fn(),
  getOptions: jest.fn(),
  getPreHeaderPanel: jest.fn(),
  getData: () => dataViewStub,
  getEditorLock: () => getEditorLockMock,
  getUID: () => GRID_UID,
  invalidate: jest.fn(),
  registerPlugin: jest.fn(),
  updateColumnHeader: jest.fn(),
  onColumnsReordered: new Slick.Event(),
  onHeaderCellRendered: new Slick.Event(),
  onHeaderMouseEnter: new Slick.Event(),
  onMouseEnter: new Slick.Event(),
} as unknown as SlickGrid;
AlexandrChazovcommented, Nov 30, 2022

My app is created by CRA. I receive this error when try to test by Jest a page that contains a SlickGrid table. Actually I don’t want to test a table itself but Jest renders a table and encounters the error. Could you please suggest me how can I get rid of this error to continue writing tests? I tried to setup Jest to manage styles as it described on official site but it doesn’t help me ((

Error: Cannot find stylesheet.
    at getColumnCssRules (C:\work\writeup\node_modules\slickgrid-es6\dist\webpack:\src\slick.grid.js:1015:15)
    at applyColumnWidths (C:\work\writeup\node_modules\slickgrid-es6\dist\webpack:\src\slick.grid.js:1190:14)
    at updateCanvasWidth (C:\work\writeup\node_modules\slickgrid-es6\dist\webpack:\src\slick.grid.js:476:7)
    at updateRowCount (C:\work\writeup\node_modules\slickgrid-es6\dist\webpack:\src\slick.grid.js:1827:5)
    at resizeCanvas (C:\work\writeup\node_modules\slickgrid-es6\dist\webpack:\src\slick.grid.js:1749:5)
    at finishInitialization (C:\work\writeup\node_modules\slickgrid-es6\dist\webpack:\src\slick.grid.js:314:7)
    at init (C:\work\writeup\node_modules\slickgrid-es6\dist\webpack:\src\slick.grid.js:281:7)
    at new SlickGrid (C:\work\writeup\node_modules\slickgrid-es6\dist\webpack:\src\slick.grid.js:3643:3)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Sass "Error: Can't find stylesheet to import." - Stack Overflow
It seems like this is a path issue; _functions.scss is in the same directory as bootstrap.scss in node_modules/bootstrap/scss , but it seems ...
Read more >
Error: Can't find stylesheet to import. · Issue #3269 - GitHub
Sass version is 1.49.9 compiled with dart2js 2.16.1. ParcelJS solved my problem by being able to compile my Sass/Scss code into plain CSS...
Read more >
Executing Sass - Can't find stylesheet to import - Syncfusion
So I import the base styles, then I override some scss variables, and then import the button styles. And in the runtime, this...
Read more >
SCSS Error: Can't find stylesheet to import.
the error comes from SASS compiler, not from the IDE. IDE tricks, like marking folders as Resource roots, won't work here, the compiler...
Read more >
Laravel NPM run Dev error "Can't find stylesheet to import."
README me of compass package. And the compass itself is a ruby gem it seems. So I don't get what you're trying to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found