Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ packages/*/test/**/*.d.ts.map
# Core
packages/blockly/tests/compile/main_compressed.js
packages/blockly/tests/compile/main_compressed.js.map
packages/blockly/tests/mocha/test-modules.generated.mjs
packages/blockly/temp/

# Docs:
# Docs:
# Autogenerated reference docs, do not check in
packages/docs/docs/reference/
packages/docs/.docusaurus
120 changes: 120 additions & 0 deletions package-lock.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ export class RenderedWorkspaceComment
this.disposing = true;
const focusManager = getFocusManager();
if (focusManager.getFocusedNode() === this) {
setTimeout(() => focusManager.focusTree(this.workspace), 0);
setTimeout(() => {
if (focusManager.isRegistered(this.workspace)) {
focusManager.focusTree(this.workspace);
}
}, 0);
}
if (!this.view.isDeadOrDying()) this.view.dispose();

Expand Down
6 changes: 6 additions & 0 deletions packages/blockly/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"browser": {
"jsdom": false
},
"imports": {
"#core/*": "./build/src/core/*",
"#generators/*": "./build/src/generators/*"
},
"scripts": {
"build": "gulp build",
"build-debug": "gulp build --verbose --debug",
Expand All @@ -42,6 +46,7 @@
"tsc": "gulp tsc",
"test": "gulp test",
"test:browser": "npx mocha --config tests/browser/.mocharc.js",
"test:mocha:node": "npx mocha --config tests/mocha/.mocharc.node.cjs \"tests/mocha/**/*_test.js\"",
"test:generators": "gulp testGenerators",
"test:mocha:interactive": "npm run build && concurrently -n tsc,server \"tsc --watch --preserveWatchOutput --outDir \"build/src\" --declarationDir \"build/declarations\"\" \"gulp interactiveMocha\"",
"test:compile:advanced": "gulp buildAdvancedCompilationTest --debug",
Expand Down Expand Up @@ -130,6 +135,7 @@
"puppeteer-core": "^25.3.0",
"readline-sync": "^1.4.10",
"rimraf": "^6.1.3",
"sinon": "^9.2.4",
"typescript": "^6.0.3",
"typescript-eslint": "^8.62.1",
"webdriverio": "^9.30.0",
Expand Down
52 changes: 32 additions & 20 deletions packages/blockly/scripts/gulpfiles/test_tasks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
/* eslint-env node */

import asyncDone from 'async-done';
import {spawnSync} from 'child_process';
import * as fs from 'fs';
import {globSync} from 'glob';
import * as gulp from 'gulp';
import gzip from 'gulp-gzip';
import * as fs from 'fs';
import * as path from 'path';
import {spawnSync} from 'child_process';
import {rimraf} from 'rimraf';

import {RELEASE_DIR, TEST_TSC_OUTPUT_DIR} from './config.mjs';
Expand Down Expand Up @@ -263,6 +264,22 @@ async function metadata() {
});
}

/**
* Generates tests/mocha/test-modules.generated.mjs,
* the list of tests imported by the browser harness (tests/mocha/index.html).
* Keeping it generated from a glob means new *_test.js files are picked up
* automatically and the browser and Node runners stay in sync.
* @return {Promise} Asynchronous result.
*/
function generateMochaIndex() {
Comment thread
gonfunko marked this conversation as resolved.
return runTestTask('generateMochaIndex', async () => {
const files = globSync('**/*_test.js', {cwd: 'tests/mocha'}).sort();

const body = files.map((f) => `import './${f}';`).join('\n') + '\n';
fs.writeFileSync('tests/mocha/test-modules.generated.mjs', body);
});
}

/**
* Run Mocha tests inside a browser.
* @return {Promise} Asynchronous result.
Expand All @@ -277,16 +294,19 @@ function mocha() {
* Run Mocha tests inside a browser and keep the browser open upon completion.
* @return {Promise} Asynchronous result.
*/
export function interactiveMocha() {
return runTestTask('interactiveMocha', () => {
return runMochaTestsInBrowser(false).then((result) => {
if (result) {
throw new Error('Mocha tests failed');
}
console.log('Mocha tests passed');
export const interactiveMocha = gulp.series(
generateMochaIndex,
function interactiveMochaRun() {
return runTestTask('interactiveMocha', () => {
return runMochaTestsInBrowser(false).then((result) => {
if (result) {
throw new Error('Mocha tests failed');
}
console.log('Mocha tests passed');
});
});
});
}
},
);

/**
* Helper method for comparison file.
Expand Down Expand Up @@ -373,14 +393,6 @@ export async function generators() {
});
}

/**
* Run Node tests.
* @return {Promise} Asynchronous result.
*/
function node() {
return runTestCommand('node', 'mocha tests/node --config tests/node/.mocharc.js');
}

/**
* Attempt advanced compilation of a Blockly app.
* @returns {Promise} Async result.
Expand Down Expand Up @@ -417,9 +429,9 @@ const tasks = [
// Build must run before the remaining tasks
build,
renamings,
generateMochaIndex,
mocha,
generators,
node,
typeDefinitions,
// Make sure these two are in series with each other
advancedCompile,
Expand Down
Loading
Loading