Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for running manual and automated tests written in TS. #886

Merged
merged 4 commits into from
Jun 1, 2023
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
4 changes: 2 additions & 2 deletions packages/ckeditor5-dev-tests/lib/tasks/runautomatedtests.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const transformFileOptionToTestGlob = require( '../utils/transformfileoptiontote
// that matches to these patterns, the file will be skipped.
const IGNORE_GLOBS = [
// Ignore files which are saved in `manual/` directory. There are manual tests.
path.join( '**', 'tests', '**', 'manual', '**', '*.js' ),
path.join( '**', 'tests', '**', 'manual', '**', '*.{js,ts}' ),
// Ignore `_utils` directory as well because there are saved utils for tests.
path.join( '**', 'tests', '**', '_utils', '**', '*.js' )
path.join( '**', 'tests', '**', '_utils', '**', '*.{js,ts}' )
];

// An absolute path to the entry file that will be passed to Karma.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = function compileHtmlFiles( options ) {
const sourceFilePathBases = sourceMDFiles.map( mdFile => getFilePathWithoutExtension( mdFile ) );
const staticFiles = _.flatten( sourceDirs.map( sourceDir => {
return globSync( path.join( sourceDir, '**', '*.!(js|html|md)' ) );
} ) ).filter( file => !file.match( /\.(js|html|md)$/ ) );
} ) ).filter( file => !file.match( /\.(js|ts|html|md)$/ ) );
const languagesToLoad = [];

if ( options.additionalLanguages ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function getWebpackEntryPoints( entryFiles ) {
const entryObject = {};

entryFiles.forEach( file => {
entryObject[ getRelativeFilePath( file ).replace( /\.js$/, '' ) ] = file;
entryObject[ getRelativeFilePath( file ).replace( /\.[jt]s$/, '' ) ] = file;
} );

return entryObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const path = require( 'path' );
const EXTERNAL_DIR_PATH = path.join( process.cwd(), 'external' );

/**
* Converts values of `--files` argument to proper globs. These are the supported types of values:
* Converts values of `--files` argument to proper globs. Handles both JS and TS files. These are the supported types of values:
* * "ckeditor5" - matches all root package tests.
* * "<external-package-name>" - matches tests in root of external package.
* * "*" - matches all packages' files.
Expand Down Expand Up @@ -64,8 +64,8 @@ module.exports = function transformFileOptionToTestGlob( pattern, isManualTest =
*/
function getExternalRepositoryGlob( pattern, { isManualTest } ) {
const repositoryGlob = isManualTest ?
path.join( EXTERNAL_DIR_PATH, pattern, 'tests', 'manual', '**', '*' ) + '.js' :
path.join( EXTERNAL_DIR_PATH, pattern, 'tests', '**', '*' ) + '.js';
path.join( EXTERNAL_DIR_PATH, pattern, 'tests', 'manual', '**', '*' ) + '.{js,ts}' :
path.join( EXTERNAL_DIR_PATH, pattern, 'tests', '**', '*' ) + '.{js,ts}';

return [
repositoryGlob.split( path.sep ).join( path.posix.sep )
Expand Down Expand Up @@ -118,7 +118,7 @@ function transformSinglePattern( pattern, options ) {
output.push( 'manual' );
}

output.push( ...chunks, '**', `${ filename }.js` );
output.push( ...chunks, '**', `${ filename }.{js,ts}` );

return output.join( path.posix.sep );
}
2 changes: 2 additions & 0 deletions packages/ckeditor5-dev-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"@ckeditor/ckeditor5-dev-translations": "^38.0.0-alpha.0",
"@ckeditor/ckeditor5-dev-utils": "^38.0.0-alpha.0",
"@ckeditor/ckeditor5-inspector": "^4.0.0",
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"assertion-error": "^1.1.0",
"babel-plugin-istanbul": "^6.1.0",
"buffer": "^6.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,38 @@ describe( 'compileManualTestScripts', () => {
} );
} );

it( 'should pass correct entries object to the webpack for both JS and TS files', async () => {
await compileManualTestScripts( {
buildDir: 'buildDir',
patterns: [ 'manualTestPattern' ],
sourceFiles: [
'ckeditor5-foo\\manual\\file1.js',
'ckeditor5-foo\\manual\\file2.ts'
],
themePath: 'path/to/theme',
language: 'en',
additionalLanguages: [ 'pl', 'ar' ],
debug: [ 'CK_DEBUG' ],
disableWatch: false
} );

expect( stubs.getWebpackConfig.calledOnce ).to.equal( true );
expect( stubs.getWebpackConfig.firstCall.args[ 0 ] ).to.deep.include( {
entries: {
'ckeditor5-foo\\manual\\file1': 'ckeditor5-foo\\manual\\file1.js',
'ckeditor5-foo\\manual\\file2': 'ckeditor5-foo\\manual\\file2.ts'
}
} );

expect( stubs.webpack.calledOnce ).to.equal( true );
expect( stubs.webpack.firstCall.args[ 0 ] ).to.deep.include( {
entries: {
'ckeditor5-foo\\manual\\file1': 'ckeditor5-foo\\manual\\file1.js',
'ckeditor5-foo\\manual\\file2': 'ckeditor5-foo\\manual\\file2.ts'
}
} );
} );

it( 'should pass the "tsconfig" option to webpack configuration factory', async () => {
await compileManualTestScripts( {
cwd: 'workspace',
Expand Down
Loading