Skip to main content

weft_runtime_fake 0.7.0-dev.3 copy "weft_runtime_fake: ^0.7.0-dev.3" to clipboard
weft_runtime_fake: ^0.7.0-dev.3 copied to clipboard

Scripted fake JsRuntimeBackend for Weft contract tests and examples.

weft_runtime_fake #

Scripted fake JsRuntimeBackend for Weft contract tests and examples.

It behaves like a runtime without executing JavaScript: each script id maps to a Dart behavior that can return a value, call the capability bridge, allocate fake heap or produce a failure with the same shape real backends use.

Usage #

import 'package:weft_runtime_fake/weft_runtime_fake.dart';

final backend = FakeRuntimeBackend(
  behaviors: {
    'contract/returns-value': (context) => const JsResult.success(42),
    'contract/infinite-loop': (context) =>
        JsResult.error(RuntimeFailure.timeout('interrupted')),
  },
);

FakeScriptContext exposes the execution budget, the capability bridge and a fake heap, so a test can assert that a script respects limits without paying for a native engine.

Where it is used #

  • The weft package's widget tests (interaction flows without native code).
  • example/weft_lab, so the sample runs on any desktop target.
  • Contract tests for the gateway, which need deterministic capability traffic.

License #

MIT.

0
likes
0
points
786
downloads

Publisher

unverified uploader

Weekly Downloads

Scripted fake JsRuntimeBackend for Weft contract tests and examples.

Repository (GitHub)
View/report issues

Topics

#javascript #testing #runtime

License

unknown (license)

Dependencies

weft_runtime_api

More

Packages that depend on weft_runtime_fake