Contribute to this guide

Testing helpers

The getData() and setData() functions exposed by model developer utilities and view developer utilities are useful development helpers.

They allow for “stringifying” the model and view structures, selections, ranges, and positions as well as for loading them from a string. They are often used when writing tests.

Both tools are designed for prototyping, debugging, and testing purposes. Do not use them in production-grade code.

For instance, to take a peek at the editor model, you could use the getData() helper:

import { _getModelData } from 'ckeditor5';

// More imports.
// ...

ClassicEditor
	.create( '<p>Hello <b>world</b>!</p>' )
	.then( editor => {
		console.log( getData( editor.model ) );
		// -> '<paragraph>[]Hello <$text bold="true">world</$text>!</paragraph>'
	} );

See the helper documentation to learn more about useful options.