ginkgo icon indicating copy to clipboard operation
ginkgo copied to clipboard

Make it possible to build tests for JS/WASM environments.

Open llamerada-jp opened this issue 3 years ago • 1 comments

Hi, I'm trying to run tests written using ginkgo in JS/WASM environments. With the current code, we get the following error at build time.

$ GOOS=js GOARCH=wasm ginkgo build ./test/wasm/
Compiling wasm...
Failed to compile wasm:

# github.com/onsi/ginkgo
../../ginkgo/ginkgo_dsl.go:261:108: undefined: remote.NewOutputInterceptor

By this PR, I could build my tests. I could also run the test by using the following HTML along with it. I was wondering if I should split the files because the file names and contents would not match, but once I created this PR. I hope anyone can give me some advice.

<!doctype html>
<html lang="en">
<head>
  <title>test colonio</title>
  <meta charset="utf-8">
</head>
<body>
  <!-- copy wasm_exec.js from $(shell go env GOROOT)/misc/wasm/wasm_exec.js -->
  <script src="wasm_exec.js" type="text/javascript"></script>
  <script type="text/javascript">
    const go = new Go();
    // rename output file to `test.wasm`
    WebAssembly.instantiateStreaming(fetch("test.wasm"), go.importObject).then((result) => {
      go.run(result.instance);
    }).catch((err) => {
      console.error(err);
    });
  </script>
</body>
</html>

The following is an example of the output from the actual test run.

image

Signed-off-by: Yuji Ito [email protected]

llamerada-jp avatar Aug 15 '21 09:08 llamerada-jp

Cool - I don't know too much about WASM support but will try to take a look at this PR in the next couple of weeks.

onsi avatar Aug 16 '21 18:08 onsi

I closed this PR because Ginko did major updates and had big changes.

llamerada-jp avatar Feb 21 '23 00:02 llamerada-jp