silverstripe / silverstripe-versioned-snapshot-admin

An administrative UI for the versioned-snapshots module
BSD 3-Clause "New" or "Revised" License
5 stars 10 forks source link

Failing JS tests #90

Open mfendeksilverstripe opened 2 years ago

mfendeksilverstripe commented 2 years ago

Failing JS tests

Looks like some of our JS tests are failing. This was noticed as a part of https://github.com/silverstripe/silverstripe-versioned-snapshot-admin/pull/86 which made the JS tests to be executed via Github actions.

Test Suites: 5 failed, 2 passed, 7 total
Tests:       15 failed, 32 passed, 47 total
Snapshots:   0 total
Time:        4.843s
Ran all test suites.

This is likely outdated test setup, not necessarily broken functionality. We should consider working on this in the context of https://github.com/silverstripe/silverstripe-versioned-snapshot-admin/issues/47 which may change a lot of tests.

The whole test suite was disabled as it's very outdated. We need to re-enable it once the tests are updated. Example of dependency errors that occur:

  ● Test suite failed to run

    Cannot find module 'babel-plugin-transform-object-rest-spread'
    Require stack:
    - /home/runner/work/silverstripe-versioned-snapshot-admin/silverstripe-versioned-snapshot-admin/node_modules/@babel/core/lib/config/files/plugins.js
    - /home/runner/work/silverstripe-versioned-snapshot-admin/silverstripe-versioned-snapshot-admin/node_modules/@babel/core/lib/config/files/index.js
    - /home/runner/work/silverstripe-versioned-snapshot-admin/silverstripe-versioned-snapshot-admin/node_modules/@babel/core/lib/index.js
    - /home/runner/work/silverstripe-versioned-snapshot-admin/silverstripe-versioned-snapshot-admin/node_modules/jest-snapshot/build/InlineSnapshots.js
    - Did you mean "@babel/transform-object-rest-spread"?
GuySartorelli commented 7 months ago

Note that you may be able to get jest tests limping along by making the following changes:

{
  "devDependencies":
  {
+    "react-16": "npm:react@^16.14.0",
+    "react-dom-16": "npm:react-dom@^16.14.0",
  },
  "jest": {
+    "testEnvironment": "jsdom",
+    "moduleNameMapper": {
+          "^react-dom/client$": "react-dom-16",
+          "^react-dom((/.*)?)$": "react-dom-16$1",
+          "^react((/.*)?)$": "react-16$1"
    }
}

Though note that that's a very hacky workaround, and results in testing how the components would work with react 16, not how they do work with react 18.

See PRs attached to https://github.com/silverstripe/silverstripe-admin/issues/1419 and the discussion in that issue for how we tackled updating our jest tests for the supported modules.