Skip to content

Commit

Permalink
Add React version test setup validation test
Browse files Browse the repository at this point in the history
  • Loading branch information
greglittlefield-wf committed Feb 11, 2025
1 parent 39a11c6 commit 5af2504
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/unit/react_version_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@JS()
library react_version_test;

import 'package:js/js.dart';
import 'package:test/test.dart';

void main() {
// This test helps us verify our test setup, ensuring
// we're running on the React version we expect to be.
test('Setup check: window.React is React 18', () {
expect(reactVersion, startsWith('18.'));
});

// TODO: Once we do a dual-CI setup, we can conditionall verify this using tags
// test('Setup check: window.React is React 17', () {
// expect(reactVersion, startsWith('17.'));
// }, tags: 'react-17');
// test('Setup check: window.React is React 18', () {
// expect(reactVersion, startsWith('18.'));
// }, tags: 'react-18');
// Then, when running tests:
// - on React 17: `dart run build_runner test -- ... --exclude-tags=react-18`
// - on React 18: `dart run build_runner test -- ... --exclude-tags=react-17`
}

@JS('React.version')
external String get reactVersion;

0 comments on commit 5af2504

Please sign in to comment.