quasarframework / quasar-testing

Testing Harness App Extensions for the Quasar Framework 2.0+
https://testing.quasar.dev
MIT License
179 stars 65 forks source link

fix(jest): fix path to stub.css #313

Open mariovor opened 1 year ago

mariovor commented 1 year ago

What kind of change does this PR introduce? (check at least one)

If you are adding a new test runner, have you...? (check all)

Does this PR introduce a breaking change? (check one)

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

Other information: I encountered an error

 Configuration error:

    Could not locate module src/css/table_styles.css mapped as:
    @quasar/quasar-app-extension-testing-unit-jest/stub.css.

    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/.*css$/": "@quasar/quasar-app-extension-testing-unit-jest/stub.css"
      },
      "resolver": undefined
    }

      1 | import { ColDef } from 'ag-grid-enterprise';
    > 2 | import 'src/css/table_styles.css';
        | ^

which is fixed on my site with the change of path to the stub.css.

IlCallo commented 1 year ago

Not sure what's happening in your case, but stub.css is copied over to the dist folder when running build script, so the current mapping is already correct and AFAIK it works on a newly generated project

Have you tried reinstalling your dependencies? Could you check node_modules/@quasar/quasar-app-extensions-testing-unit-jest/dist and let me know if you see stub.css inside it?

mariovor commented 1 year ago

I see stub.css in the dist folder. No idea why I get this error.

IlCallo commented 1 year ago

Can you reproduce this into a clean project?

mariovor commented 1 year ago

I created a new project, added a css file and import it in the MyButton.vue demo file

grafik

 FAIL  test/jest/__tests__/MyButton.spec.js
  ● Test suite failed to run

    Configuration error:

    Could not locate module ./css/table_styles.css mapped as:
    @quasar/quasar-app-extension-testing-unit-jest/stub.css.

    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/.*css$/": "@quasar/quasar-app-extension-testing-unit-jest/stub.css"
      },
      "resolver": undefined
    }

      1 | <script>
      2 | import { defineComponent, ref } from 'vue';
    > 3 | import './css/table_styles.css'
        | ^
      4 |
      5 | export default defineComponent({
      6 |   name: 'MyButton',

      at createNoMappedModuleFoundError (node_modules/jest-resolve/build/resolver.js:752:17)
      at Object.<anonymous> (test/jest/__tests__/demo/MyButton.vue:3:1)
      at Object.<anonymous> (test/jest/__tests__/MyButton.spec.js:5:1)