mberlanda / cheidelacoriera

This Rails application aims to become a management system for away fans.
GNU General Public License v3.0
2 stars 1 forks source link

Add jest support and ts unit tests #209

Closed mberlanda closed 2 years ago

mberlanda commented 2 years ago

https://blog.arkency.com/testing-react-dot-js-components-with-jest-in-rails-plus-webpacker-plus-webpack-environment/ https://www.npmjs.com/package/@wojtekmaj/enzyme-adapter-react-17 https://webpacker-docs.netlify.app/docs/testing

mberlanda commented 2 years ago

87092c2 is not working because tests are running on node_modules and vendor folder as well. Need to rework it this weekend and push --force the fix :

FAIL vendor/bundle/ruby/2.7.0/gems/webpacker-5.4.3/package/environments/__tests__/base.js
  ● Environment › toWebpackConfig › should return multi file entry points

    TypeError: Cannot read property 'sort' of undefined

      32 |     test('should return multi file entry points', () => {
      33 |       const config = environment.toWebpackConfig()
    > 34 |       expect(config.entry.multi_entry.sort()).toEqual([
         |                                       ^
      35 |         resolve('app', 'javascript', 'packs', 'multi_entry.css'),
      36 |         resolve('app', 'javascript', 'packs', 'multi_entry.js')
      37 |       ])

      at Object.<anonymous> (vendor/bundle/ruby/2.7.0/gems/webpacker-5.4.3/package/environments/__tests__/base.js:34:39)

  ● Environment › toWebpackConfig › should return default resolve.modules with additions

    expect(received).toEqual(expected) // deep equality

    - Expected  - 3
    + Received  + 0

      Array [
        "/home/runner/work/cheidelacoriera/cheidelacoriera/app/javascript",
    -   "/home/runner/work/cheidelacoriera/cheidelacoriera/app/assets",
    -   "/etc/yarn",
    -   "/home/runner/work/cheidelacoriera/cheidelacoriera/app/elm",
        "node_modules",
      ]

      83 |     test('should return default resolve.modules with additions', () => {
      84 |       const config = environment.toWebpackConfig()
    > 85 |       expect(config.resolve.modules).toEqual([
         |                                      ^
      86 |         resolve('app', 'javascript'),
      87 |         resolve('app/assets'),
      88 |         resolve('/etc/yarn'),

      at Object.<anonymous> (vendor/bundle/ruby/2.7.0/gems/webpacker-5.4.3/package/environments/__tests__/base.js:85:38)

PASS vendor/bundle/ruby/2.7.0/gems/webpacker-5.4.3/package/config_types/__tests__/config_list.js
PASS vendor/bundle/ruby/2.7.0/gems/webpacker-5.4.3/package/utils/__tests__/get_style_rule.js
FAIL vendor/bundle/ruby/2.7.0/gems/webpacker-5.4.3/package/__tests__/config.js
  ● Config › should return additional paths as listed in app config, with resolved paths

    expect(received).toEqual(expected) // deep equality

    - Expected  - 5
    + Received  + 1

    - Array [
    -   "app/assets",
    -   "/etc/yarn",
    -   "app/elm",
    - ]
    + Array []

      25 |
      26 |   test('should return additional paths as listed in app config, with resolved paths', () => {
    > 27 |     expect(config.additional_paths).toEqual(
         |                                     ^
      28 |       [
      29 |         'app/assets',
      30 |         '/etc/yarn',

      at Object.<anonymous> (vendor/bundle/ruby/2.7.0/gems/webpacker-5.4.3/package/__tests__/config.js:27:37)

  ● Config › should return extensions as listed in app config

    expect(received).toEqual(expected) // deep equality