sidlatau / neotest-dart

30 stars 8 forks source link

Not working for widget tests #4

Closed Chaitanyabsprip closed 1 year ago

Chaitanyabsprip commented 1 year ago
image

when I run require('neotest').run.run() on this test, I get a notification saying no tests found.

however when I run the tests from the summary window, I get the following output

image
{"protocolVersion":"0.1.1","runnerVersion":null,"pid":72629,"type":"start","time":0}
{"suite":{"id":0,"platform":"vm","path":"/Users/chaitanyasharma/Projects/ApplicationDevelopment/minesweeper/test/pages/game_menu_test.dart"},"type":"suite","time":0}
{"test":{"id":1,"name":"loading /Users/chaitanyasharma/Projects/ApplicationDevelopment/minesweeper/test/pages/game_menu_test.dart","suiteID":0,"groupIDs":[],"metadat
a":{"skip":false,"skipReason":null},"line":null,"column":null,"url":null},"type":"testStart","time":0}
{"count":1,"time":3,"type":"allSuites"}
{"testID":1,"result":"success","skipped":false,"hidden":true,"type":"testDone","time":1757}
{"group":{"id":2,"suiteID":0,"parentID":null,"name":"","metadata":{"skip":false,"skipReason":null},"testCount":1,"line":null,"column":null,"url":null},"type":"group"
,"time":1758}
{"group":{"id":3,"suiteID":0,"parentID":2,"name":"menu","metadata":{"skip":false,"skipReason":null},"testCount":1,"line":6,"column":3,"url":"file:///Users/chaitanyas
harma/Projects/ApplicationDevelopment/minesweeper/test/pages/game_menu_test.dart"},"type":"group","time":1759}
{"test":{"id":4,"name":"menu should show new game button","suiteID":0,"groupIDs":[2,3],"metadata":{"skip":false,"skipReason":null},"line":154,"column":5,"url":"packa
ge:flutter_test/src/widget_tester.dart","root_line":7,"root_column":5,"root_url":"file:///Users/chaitanyasharma/Projects/ApplicationDevelopment/minesweeper/test/page
s/game_menu_test.dart"},"type":"testStart","time":1759}
{"testID":4,"result":"success","skipped":false,"hidden":false,"type":"testDone","time":2649}
{"success":true,"type":"done","time":2667}
sidlatau commented 1 year ago

Hm, I am not able to reproduce it. Could you provide full test file content?

Chaitanyabsprip commented 1 year ago
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:minesweeper/minesweeper/pages/game_menu.dart';

void main() {
  group('menu', () {
    testWidgets('should show new game button', (tester) async {
      await const GameMenu().pump(tester);
      expect(find.text('New Game'), findsOneWidget);
    });
  });
}

extension MaterialTest on Widget {
  Future<void> pump(WidgetTester tester) async {
    await tester.pumpWidget(MaterialApp(home: this));
  }
}
Chaitanyabsprip commented 1 year ago

I have use_lsp on and my command is fvm flutter

sidlatau commented 1 year ago

Hm, I am unable to reproduce it:

image

But I see that the menu group is not visible in the summary (but it is visible in text output). Did you provide a full test file? Also, maybe it is related to the flutter version - which flutter version you are using?

Chaitanyabsprip commented 1 year ago

I somehow fixed the error that I was having, it seems to have been an issue in setting up keymaps with lazy.nvim(Probably something to do with how lazy.nvim lazy loads the dependencies of neotest). Not sure what the exact error is, but I'll try to reproduce and either add it to lazy.nvim discussions or comment on this issue itself, in-case someone else faces a similar issue.

Also I can see the menu group in the summary. Answering your question anyway, I did provide the complete test file that could reproduce error on my setup. I am on the latest flutter version.