Skip to content

Commit

Permalink
fix: import @testing-library/jest-dom matchers in their own setup s…
Browse files Browse the repository at this point in the history
…cript

Technically we could just add the import to `setupFilesAfterEnv`, but then they'd not get picked
up by TypeScript since we wouldn't actually be "importing" them in a TS file.
  • Loading branch information
G-Rath committed Aug 14, 2023
1 parent 2d8db4d commit a27235a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion variants/frontend-stimulus-typescript/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const config: Config.InitialOptions = {

testPathIgnorePatterns: ['config/'],
setupFilesAfterEnv: [
'@testing-library/jest-dom/extend-expect',
'./app/frontend/test/setupJestDomMatchers.ts',
'./app/frontend/test/setupExpectEachTestHasAssertions.ts'
],

Expand Down
1 change: 1 addition & 0 deletions variants/frontend-stimulus-typescript/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
remove_file "app/frontend/stimulus/controllers/add_class_controller.js", force: true
copy_file "app/frontend/stimulus/controllers/add_class_controller.ts"

rename_js_file_to_ts "app/frontend/test/setupJestDomMatchers"
rename_js_file_to_ts "app/frontend/test/setupExpectEachTestHasAssertions"
rename_js_file_to_ts "app/frontend/test/stimulus/controllers/add_class_controller.test"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// this makes the jest-dom matchers available on `expect`
import '@testing-library/jest-dom';
2 changes: 1 addition & 1 deletion variants/frontend-stimulus/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const config = {

testPathIgnorePatterns: ['config/'],
setupFilesAfterEnv: [
'@testing-library/jest-dom/extend-expect',
'./app/frontend/test/setupJestDomMatchers.js',
'./app/frontend/test/setupExpectEachTestHasAssertions.js'
]
};
Expand Down

0 comments on commit a27235a

Please sign in to comment.