Skip to content

Commit

Permalink
fix(tests): Fix node tests
Browse files Browse the repository at this point in the history
run_node_test.js previously directly require()d the dist/blockly.js
and dist/javascript.js wrapper module, which no longer exist.

Change it to require('blockly-test') (and …blockly-test/javascript)
and create a symlink ./node_modules/blocky-test -> dist/ to satisfy
this.
  • Loading branch information
cpcallen committed Feb 1, 2024
1 parent a5f3a72 commit 73a603b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions tests/node/node_modules/blockly-test

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 19 additions & 5 deletions tests/node/run_node_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @fileoverview Mocha tests that test Blockly in Node.
*/
/** @fileoverview Mocha tests that test Blockly in Node. */

console.log(process.cwd());

// N.B. the file ./node_modules/blockly-test should be a symlink to
// RELEASE_DIR (i.e. dist/) so that require will load the packaged
// version of blockly as if it were an external dependency.
//
// Moreover, (as with the typescript tests) this link has to be
// called something other than "blockly", because the node module
// resolution will favour loading the nearest enclosing package
// of the same name, which means that require('blockly') will load
// based on the exports section of the package.json in the repository
// root, but this fails because (at the time of writing) those paths
// are relative to RELEASE_DIR (dist/, into which package.json is
// copied when packaged), resulting in require() looking for the
// compressed bundles in the wrong place.

const assert = require('chai').assert;
const Blockly = require('../../dist/');
const {javascriptGenerator} = require('../../dist/javascript');
const Blockly = require('blockly-test');
const {javascriptGenerator} = require('blockly-test/javascript');

const xmlText =
'<xml xmlns="https://developers.google.com/blockly/xml">\n' +
Expand Down

0 comments on commit 73a603b

Please sign in to comment.