From aa116a23161314a52fc9e24587a7dfb5ebbe3cda Mon Sep 17 00:00:00 2001 From: TruongSinh Tran-Nguyen Date: Fri, 28 Jun 2019 09:29:44 +0700 Subject: [PATCH] test(client): explicitly skip non-VM Because we are using a workaround for running test on browser we cannot rely only on `@TestOn("vm")` ``` # cannot `run pub run test test/.test_coverage.dart -p chromium` # it randomly fails compiling some dart files to js # test/.test_coverage.dart is a by product of running # `pub run test_coverage` pub run test test/.test_coverage.dart -p chromium ``` --- .../test/multipart_upload_io_test.dart | 88 ++++++++++--------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/packages/graphql/test/multipart_upload_io_test.dart b/packages/graphql/test/multipart_upload_io_test.dart index eaeb7ede6..d13d763ef 100644 --- a/packages/graphql/test/multipart_upload_io_test.dart +++ b/packages/graphql/test/multipart_upload_io_test.dart @@ -18,8 +18,10 @@ void main() { GraphQLClient graphQLClientClient; MockHttpClient mockHttpClient; - group('upload', () { - const String uploadMutation = r''' + group( + 'upload', + () { + const String uploadMutation = r''' mutation($files: [Upload!]!) { multipleUpload(files: $files) { id @@ -30,44 +32,45 @@ void main() { } '''; - setUp(() { - mockHttpClient = MockHttpClient(); + setUp(() { + mockHttpClient = MockHttpClient(); - when(mockHttpClient.send(any)).thenAnswer((Invocation a) async { - return simpleResponse(body: '{"data": {}}'); - }); + when(mockHttpClient.send(any)).thenAnswer((Invocation a) async { + return simpleResponse(body: '{"data": {}}'); + }); - httpLink = HttpLink( - uri: 'http://localhost:3001/graphql', httpClient: mockHttpClient); + httpLink = HttpLink( + uri: 'http://localhost:3001/graphql', httpClient: mockHttpClient); - authLink = AuthLink( - getToken: () async => 'Bearer my-special-bearer-token', - ); + authLink = AuthLink( + getToken: () async => 'Bearer my-special-bearer-token', + ); - link = authLink.concat(httpLink); + link = authLink.concat(httpLink); - graphQLClientClient = GraphQLClient( - cache: getTestCache(), - link: link, - ); - }); + graphQLClientClient = GraphQLClient( + cache: getTestCache(), + link: link, + ); + }); - test('upload with io.File instance deprecation warning', + test( + 'upload with io.File instance deprecation warning', overridePrint((log) async { - final MutationOptions _options = MutationOptions( - document: uploadMutation, - variables: { - 'files': [ - io.File('pubspec.yaml'), - ], - }, - ); - final QueryResult r = await graphQLClientClient.mutate(_options); - - expect(r.errors, isNull); - expect(r.data, isNotNull); - expect(log, hasLength(5)); - final warningMessage = r''' + final MutationOptions _options = MutationOptions( + document: uploadMutation, + variables: { + 'files': [ + io.File('pubspec.yaml'), + ], + }, + ); + final QueryResult r = await graphQLClientClient.mutate(_options); + + expect(r.errors, isNull); + expect(r.data, isNotNull); + expect(log, hasLength(5)); + final warningMessage = r''' ⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️ DEPRECATION WARNING ⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️ Please do not use `File` direcly anymore. Instead, use @@ -76,11 +79,16 @@ Please do not use `File` direcly anymore. Instead, use ⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️ DEPRECATION WARNING ⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️⚠️️️️️️️️ '''; - expect(log[0], warningMessage); - expect(log[1], warningMessage); - expect(log[2], warningMessage); - expect(log[3], warningMessage); - expect(log[4], warningMessage); - })); - }); + expect(log[0], warningMessage); + expect(log[1], warningMessage); + expect(log[2], warningMessage); + expect(log[3], warningMessage); + expect(log[4], warningMessage); + }), + ); + }, + onPlatform: { + "!vm": Skip("This test is only for VM"), + }, + ); }