@@ -584,38 +584,223 @@ ruleTester.run(RULE_NAME, rule, {
584584 code : `
585585 import { screen } from '${ testingFramework } ';
586586
587- const button = document.getElementById('submit-btn'). ${ method } ();
587+ const dom = screen.getByLabelText('foo')[' ${ method } '] ();
588588 ` ,
589589 errors : [
590590 {
591591 line : 4 ,
592- column : 33 ,
592+ column : 50 ,
593593 messageId : 'noNodeAccess' ,
594594 } ,
595+ ] ,
596+ } ,
597+ {
598+ code : `
599+ import { screen } from '${ testingFramework } ';
600+
601+ const dom = screen.getByLabelText('foo').${ method } ();
602+ ` ,
603+ errors : [
595604 {
596605 line : 4 ,
597- column : 62 ,
606+ column : 50 ,
598607 messageId : 'noNodeAccess' ,
599608 } ,
600609 ] ,
601610 } ,
602611 {
603- settings : { 'testing-library/utils-module' : 'test-utils' } ,
604612 code : `
605- // case: custom module set but not imported using ${ testingFramework } (aggressive reporting limited)
606- import { screen } from 'test-utils';
613+ import { screen } from '${ testingFramework } ';
614+
615+ const dom = screen.getByPlaceholderText('foo')['${ method } ']();
616+ ` ,
617+ errors : [
618+ {
619+ line : 4 ,
620+ column : 56 ,
621+ messageId : 'noNodeAccess' ,
622+ } ,
623+ ] ,
624+ } ,
625+ {
626+ code : `
627+ import { screen } from '${ testingFramework } ';
628+
629+ const dom = screen.getByPlaceholderText('foo').${ method } ();
630+ ` ,
631+ errors : [
632+ {
633+ line : 4 ,
634+ column : 56 ,
635+ messageId : 'noNodeAccess' ,
636+ } ,
637+ ] ,
638+ } ,
639+
640+ {
641+ code : `
642+ import { screen } from '${ testingFramework } ';
643+
644+ const dom = screen.getByText('foo')['${ method } ']();
645+ ` ,
646+ errors : [
647+ {
648+ line : 4 ,
649+ column : 45 ,
650+ messageId : 'noNodeAccess' ,
651+ } ,
652+ ] ,
653+ } ,
654+ {
655+ code : `
656+ import { screen } from '${ testingFramework } ';
657+
658+ const dom = screen.getByText('foo').${ method } ();
659+ ` ,
660+ errors : [
661+ {
662+ line : 4 ,
663+ column : 45 ,
664+ messageId : 'noNodeAccess' ,
665+ } ,
666+ ] ,
667+ } ,
668+ {
669+ code : `
670+ import { screen } from '${ testingFramework } ';
671+
672+ const dom = screen.getByAltText('foo')['${ method } ']();
673+ ` ,
674+ errors : [
675+ {
676+ line : 4 ,
677+ column : 48 ,
678+ messageId : 'noNodeAccess' ,
679+ } ,
680+ ] ,
681+ } ,
682+ {
683+ code : `
684+ import { screen } from '${ testingFramework } ';
685+
686+ const dom = screen.getByAltText('foo').${ method } ();
687+ ` ,
688+ errors : [
689+ {
690+ line : 4 ,
691+ column : 48 ,
692+ messageId : 'noNodeAccess' ,
693+ } ,
694+ ] ,
695+ } ,
696+ {
697+ code : `
698+ import { screen } from '${ testingFramework } ';
699+
700+ const dom = screen.getByTitle('foo')['${ method } ']();
701+ ` ,
702+ errors : [
703+ {
704+ line : 4 ,
705+ column : 46 ,
706+ messageId : 'noNodeAccess' ,
707+ } ,
708+ ] ,
709+ } ,
710+ {
711+ code : `
712+ import { screen } from '${ testingFramework } ';
713+
714+ const dom = screen.getByTitle('foo').${ method } ();
715+ ` ,
716+ errors : [
717+ {
718+ line : 4 ,
719+ column : 46 ,
720+ messageId : 'noNodeAccess' ,
721+ } ,
722+ ] ,
723+ } ,
724+ {
725+ code : `
726+ import { screen } from '${ testingFramework } ';
607727
608- const button = document.getElementById('submit-btn'). ${ method } ();
728+ const dom = screen.getByDisplayValue('foo')[' ${ method } '] ();
609729 ` ,
610730 errors : [
611731 {
612- line : 5 ,
613- column : 33 ,
732+ line : 4 ,
733+ column : 53 ,
614734 messageId : 'noNodeAccess' ,
615735 } ,
736+ ] ,
737+ } ,
738+ {
739+ code : `
740+ import { screen } from '${ testingFramework } ';
741+
742+ const dom = screen.getByDisplayValue('foo').${ method } ();
743+ ` ,
744+ errors : [
616745 {
617- line : 5 ,
618- column : 62 ,
746+ line : 4 ,
747+ column : 53 ,
748+ messageId : 'noNodeAccess' ,
749+ } ,
750+ ] ,
751+ } ,
752+ {
753+ code : `
754+ import { screen } from '${ testingFramework } ';
755+
756+ const dom = screen.getByRole('foo')['${ method } ']();
757+ ` ,
758+ errors : [
759+ {
760+ line : 4 ,
761+ column : 45 ,
762+ messageId : 'noNodeAccess' ,
763+ } ,
764+ ] ,
765+ } ,
766+ {
767+ code : `
768+ import { screen } from '${ testingFramework } ';
769+
770+ const dom = screen.getByRole('foo').${ method } ();
771+ ` ,
772+ errors : [
773+ {
774+ line : 4 ,
775+ column : 45 ,
776+ messageId : 'noNodeAccess' ,
777+ } ,
778+ ] ,
779+ } ,
780+ {
781+ code : `
782+ import { screen } from '${ testingFramework } ';
783+
784+ const dom = screen.getByTestId('foo')['${ method } ']();
785+ ` ,
786+ errors : [
787+ {
788+ line : 4 ,
789+ column : 47 ,
790+ messageId : 'noNodeAccess' ,
791+ } ,
792+ ] ,
793+ } ,
794+ {
795+ code : `
796+ import { screen } from '${ testingFramework } ';
797+
798+ const dom = screen.getByTestId('foo').${ method } ();
799+ ` ,
800+ errors : [
801+ {
802+ line : 4 ,
803+ column : 47 ,
619804 messageId : 'noNodeAccess' ,
620805 } ,
621806 ] ,
0 commit comments