Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
riot-jest-transformer
Advanced tools
This transformer helps you to use Jest testing tool for your Riot tags. With this transformer you can import your tags into your Jest tests.
npm i --save-dev jest babel-jest
)npm i --save-dev riot-jest-transformer
.babelrc
file correctly (for more see Jest docs). Don't forget setting presets
for new javascript features. In your Riot project you may want to set es2015-riot
preset.riot-jest-transformer must be used in your Jest config file like this:
{
"transform": {
"^.+\\.jsx?$": "babel-jest",
"^.+\\.tag$": "riot-jest-transformer"
}
}
Just import your tag into the Jest test file. After that you can mount your tag to an html element. For example:
import * as riot from 'riot';
import hello from '../hello.tag'; // <hello><h1>{ opts.name }</h1></hello>
describe('hello', () => {
beforeAll( () => {
// create mounting point
const elem = document.createElement('hello');
elem.setAttribute('name', 'world');
document.body.appendChild(elem)
riot.mount(elem, 'hello');
});
it('should mount the tag', () => {
expect(document.querySelector('hello h1').textContent).toBe('world');
});
});
The transformer uses babel-core module by default as transformer for the compiled tag. You can also use other transformer by configuring it in .riot-jest-transformer
config file in the root of your project directory. The form of the config file must be like this:
{
transformer: <transformer module name or path, it will be required by Jest> : String,
method: <the used method of transformer module> : String,
args: <arguments for method> : Array
}
You can play with importing and testing tags in the demo folder:
npm i
npm test
to run a simple jest test for an example Riot tag.Run tests with npm test
or npm run test:watch
.
The transformer is developed with tdd, so if you would like to contribute (you are really welcomed :), please write your tests for your new functionality, and send pull request to integrate your changes.
FAQs
Jest transformer for testing riot tags
The npm package riot-jest-transformer receives a total of 172 weekly downloads. As such, riot-jest-transformer popularity was classified as not popular.
We found that riot-jest-transformer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.