Skip to content

feat: add support for @marko/testing-library #572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1cb00f5
feat: add support for @marko/testing-library
PrashantAshok Apr 27, 2022
9904905
feat: add tests and update documentation for @marko/testing-library
PrashantAshok Apr 28, 2022
8713744
fix: run prettier and update readme
PrashantAshok Apr 29, 2022
704003e
test: add tests for @marko/testing-library
PrashantAshok May 2, 2022
5425044
test: add marko tests for await-async-query-test
PrashantAshok May 3, 2022
5fa1ebc
chore: address review comment
PrashantAshok May 3, 2022
5211fd9
test: add marko await fire-event test case
PrashantAshok May 3, 2022
ef468b2
test: add test for no-await-sync-query
PrashantAshok May 3, 2022
c61285b
test: no container
PrashantAshok May 3, 2022
5d9fee7
test: no-debugging-utils
PrashantAshok May 3, 2022
86aa0de
test: no-dom-import
PrashantAshok May 3, 2022
f8b2287
test: no-node-access
PrashantAshok May 4, 2022
c5809fd
test: no unnecassary act
PrashantAshok May 4, 2022
114f61c
test: no-wait-for-empty-callback
PrashantAshok May 4, 2022
dc031f6
test: no-wait-for-multiple-assertions
PrashantAshok May 4, 2022
588a72c
test: no-wait-for-side-effects
PrashantAshok May 4, 2022
101485b
test: prefer-query-by-disappearance
PrashantAshok May 4, 2022
cc11827
test: prefer-screen-queries
PrashantAshok May 4, 2022
f634bfd
test: render-result-naming-convention
PrashantAshok May 4, 2022
387cda2
fix: update no-dom-import rule to report the right module name
PrashantAshok May 4, 2022
636e730
fix: address PR comments
PrashantAshok May 7, 2022
f628de5
fix: update Marko's brand logo
PrashantAshok May 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/rules/await-fire-event.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ methods.
>
> - `@testing-library/vue` (supported by this plugin)
> - `@testing-library/svelte` (not supported yet by this plugin)
> - `@marko/testing-library` (supported by this plugin)

Examples of **incorrect** code for this rule:

Expand Down
1 change: 1 addition & 0 deletions docs/rules/no-dom-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ With the configuration above, if the user imports from `@testing-library/dom` or
- [Angular Testing Library API](https://testing-library.com/docs/angular-testing-library/api)
- [React Testing Library API](https://testing-library.com/docs/react-testing-library/api)
- [Vue Testing Library API](https://testing-library.com/docs/vue-testing-library/api)
- [Marko Testing Library API](https://testing-library.com/docs/marko-testing-library/api)
1 change: 1 addition & 0 deletions docs/rules/no-unnecessary-act.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
> - `@testing-library/react` (supported by this plugin)
> - `@testing-library/preact` (not supported yet by this plugin)
> - `@testing-library/svelte` (not supported yet by this plugin)
> - `@marko/testing-library` (supported by this plugin)

## Rule Details

Expand Down
29 changes: 29 additions & 0 deletions lib/configs/marko.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// YOU CAN REGENERATE IT USING npm run generate:configs

export = {
plugins: ['testing-library'],
rules: {
'testing-library/await-async-query': 'error',
'testing-library/await-async-utils': 'error',
'testing-library/await-fire-event': 'error',
'testing-library/no-await-sync-query': 'error',
'testing-library/no-container': 'error',
'testing-library/no-debugging-utils': 'error',
'testing-library/no-dom-import': ['error', 'marko'],
'testing-library/no-node-access': 'error',
'testing-library/no-promise-in-fire-event': 'error',
'testing-library/no-render-in-setup': 'error',
'testing-library/no-unnecessary-act': 'error',
'testing-library/no-wait-for-empty-callback': 'error',
'testing-library/no-wait-for-multiple-assertions': 'error',
'testing-library/no-wait-for-side-effects': 'error',
'testing-library/no-wait-for-snapshot': 'error',
'testing-library/prefer-find-by': 'error',
'testing-library/prefer-presence-queries': 'error',
'testing-library/prefer-query-by-disappearance': 'error',
'testing-library/prefer-screen-queries': 'error',
'testing-library/render-result-naming-convention': 'error',
},
};
1 change: 1 addition & 0 deletions lib/rules/await-async-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/await-async-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/await-fire-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/consistent-data-testid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-await-sync-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-await-sync-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-debugging-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-dom-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: ['error', 'angular'],
react: ['error', 'react'],
vue: ['error', 'vue'],
marko: ['error', 'marko'],
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-global-regexp-flag-in-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-manual-cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-node-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-promise-in-fire-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-render-in-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-unnecessary-act.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: 'error',
vue: false,
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-wait-for-empty-callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-wait-for-multiple-assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-wait-for-side-effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/no-wait-for-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-explicit-assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-find-by.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-presence-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-query-by-disappearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-screen-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-user-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/prefer-wait-for.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/rules/render-result-naming-convention.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: 'error',
react: 'error',
vue: 'error',
marko: 'error'
},
},
messages: {
Expand Down
1 change: 1 addition & 0 deletions lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const LIBRARY_MODULES = [
'@testing-library/preact',
'@testing-library/vue',
'@testing-library/svelte',
'@marko/testing-library'
];

const SYNC_QUERIES_VARIANTS = ['getBy', 'getAllBy', 'queryBy', 'queryAllBy'];
Expand Down
1 change: 1 addition & 0 deletions lib/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const SUPPORTED_TESTING_FRAMEWORKS = [
'angular',
'react',
'vue',
'marko'
] as const;
export type SupportedTestingFramework =
typeof SUPPORTED_TESTING_FRAMEWORKS[number];
30 changes: 30 additions & 0 deletions tests/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,36 @@ Object {
"testing-library/prefer-screen-queries": "error",
},
},
"marko": Object {
"plugins": Array [
"testing-library",
],
"rules": Object {
"testing-library/await-async-query": "error",
"testing-library/await-async-utils": "error",
"testing-library/await-fire-event": "error",
"testing-library/no-await-sync-query": "error",
"testing-library/no-container": "error",
"testing-library/no-debugging-utils": "error",
"testing-library/no-dom-import": Array [
"error",
"marko",
],
"testing-library/no-node-access": "error",
"testing-library/no-promise-in-fire-event": "error",
"testing-library/no-render-in-setup": "error",
"testing-library/no-unnecessary-act": "error",
"testing-library/no-wait-for-empty-callback": "error",
"testing-library/no-wait-for-multiple-assertions": "error",
"testing-library/no-wait-for-side-effects": "error",
"testing-library/no-wait-for-snapshot": "error",
"testing-library/prefer-find-by": "error",
"testing-library/prefer-presence-queries": "error",
"testing-library/prefer-query-by-disappearance": "error",
"testing-library/prefer-screen-queries": "error",
"testing-library/render-result-naming-convention": "error",
},
},
"react": Object {
"plugins": Array [
"testing-library",
Expand Down
1 change: 1 addition & 0 deletions tests/fake-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
angular: false,
react: false,
vue: false,
marko: false,
},
},
messages: {
Expand Down
8 changes: 7 additions & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ it("should have run 'generate:configs' script when changing config rules", async
it('should export configs that refer to actual rules', () => {
const allConfigs = plugin.configs;

expect(Object.keys(allConfigs)).toEqual(['dom', 'angular', 'react', 'vue']);
expect(Object.keys(allConfigs)).toEqual([
'dom',
'angular',
'react',
'vue',
'marko',
]);
const allConfigRules = Object.values(allConfigs)
.map((config) => Object.keys(config.rules))
.reduce((previousValue, currentValue) => [
Expand Down