Installation
npm install node-plug
Then create a file, for example plugin.js, then create code like this
export const t = { async run() { await console.log('foo') }, } // atau /*const test = 'foo' export const t = { async run() { await console.log(test) }, }*/ // atau /*const test = { run() { console.log('foo') }, } export const t = { async run() { await test.run() }, }*/
Then create a main.js or index.js file
import { addPlugin, runPlugin, test } from 'node-plug' import { t } from './plugin.js' // Menambahkan plugin addPlugin(t) // Menjalankan plugin runPlugin() // Melakukan pengujian test(['bar'])
The code above will display:
But if:
import { addPlugin, runPlugin, test } from 'node-plug' import { t } from './plugin.js' // Menambahkan plugin addPlugin(t) // Menjalankan plugin runPlugin() // Melakukan pengujian test(['foo'])
Then the test was successfully executed
The above is the detailed content of Carrying out tests using node-plug. For more information, please follow other related articles on the PHP Chinese website!