Skip to content

Commit

Permalink
[lumino] mock DragEvent in test setup
Browse files Browse the repository at this point in the history
'@lumino/dragdrop' consumes DragEvent already at loading time.
Therefore the DragEvent mock must already be available before executing
the tests.

Adds a new private '@theia/test-setup' dev package which is consumed in
the mocha config to mock 'DragEvent' before loading and compiling
tests.

Contributed on behalf of STMicroelectronics
  • Loading branch information
sdirix committed Nov 29, 2024
1 parent 2e8a052 commit b074e61
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions configs/mocharc.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require:
- 'ignore-styles'
- 'reflect-metadata/Reflect'
- '@theia/test-setup'
reporter: 'spec'
watch-files:
- '**/*.js'
Expand Down
32 changes: 32 additions & 0 deletions dev-packages/private-test-setup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<div align='center'>

<br />

<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />

<h2>ECLIPSE THEIA - TEST SETUP</h2>

<hr />

</div>

## Description

The `@theia/test-setup` contributes a setup script for mocha executed tests in Theia.
This setup script is executed before any test file is loaded or compiled.
This is for example useful for globals which must exist before dependencies are loaded.

## Additional Information

- [Theia - GitHub](https://github.com/eclipse-theia/theia)
- [Theia - Website](https://theia-ide.org/)

## License

- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)

## Trademark

"Theia" is a trademark of the Eclipse Foundation
https://www.eclipse.org/theia
7 changes: 7 additions & 0 deletions dev-packages/private-test-setup/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"private": true,
"name": "@theia/test-setup",
"version": "1.56.0",
"description": "Custom setup for mocha tests",
"main": "test-setup.js"
}
18 changes: 18 additions & 0 deletions dev-packages/private-test-setup/test-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// *****************************************************************************
// Copyright (C) 2024 STMicroelectronics and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

// Mock DragEvent as '@lumino/dragdrop' already requires it at require time
global.DragEvent = class DragEvent { };

0 comments on commit b074e61

Please sign in to comment.