11import { addStepDefinition , findStepDefinitionMatch } from './steps' ;
22import { get , defaults } from 'lodash-es' ;
3- import { tagsFunction } from './tags' ;
3+ import { Plugin , ResolvedConfig as ViteResolvedConfig } from 'vite'
44import {
55 BeforeAll , applyBeforeAllHooks ,
66 Before , applyBeforeHooks ,
@@ -53,7 +53,7 @@ interface StepDefinitionMatch {
5353}
5454
5555export const qp = async ( step : string , state : any , line : number , data ?: any ) : Promise < any > => {
56- const stepDefinitionMatch = findStepDefinitionMatch ( step ) ;
56+ const stepDefinitionMatch : StepDefinitionMatch = findStepDefinitionMatch ( step ) ;
5757
5858 // Set the state info
5959 state . info . step = step
@@ -78,13 +78,13 @@ export const qp = async (step: string, state: any, line: number, data?: any): Pr
7878 }
7979} ;
8080
81- export type QuickPickleConfig = {
81+ export type QuickPickleConfig < T = { [ key : string ] : any } > = {
8282 todoTags : string | string [ ]
8383 skipTags : string | string [ ]
8484 failTags : string | string [ ]
8585 concurrentTags : string | string [ ]
8686 sequentialTags : string | string [ ]
87- worldConfig : { [ key : string ] : any }
87+ worldConfig : T
8888} ;
8989
9090export const defaultConfig : QuickPickleConfig = {
@@ -123,10 +123,8 @@ export const defaultConfig: QuickPickleConfig = {
123123
124124}
125125
126- interface ResolvedConfig {
127- test ?: {
128- quickpickle ?: Partial < QuickPickleConfig > ;
129- } ;
126+ interface ResolvedConfig extends ViteResolvedConfig {
127+ quickpickle ?: Partial < QuickPickleConfig > ;
130128}
131129
132130export function normalizeTags ( tags ?:string | string [ ] | undefined ) :string [ ] {
@@ -135,23 +133,24 @@ export function normalizeTags(tags?:string|string[]|undefined):string[] {
135133 return tags . filter ( Boolean ) . map ( tag => tag . startsWith ( '@' ) ? tag : `@${ tag } ` )
136134}
137135
138- export const quickpickle = function ( ) {
136+ export const quickpickle = ( passedConfig : Partial < QuickPickleConfig > = { } ) : Plugin => {
139137 let config : QuickPickleConfig ;
140138
141139 return {
142140 name : 'quickpickle-transform' ,
143- configResolved : ( resolvedConfig : ResolvedConfig ) => {
141+ configResolved ( resolvedConfig : ResolvedConfig ) {
144142 config = defaults (
145143 defaultConfig ,
146- get ( resolvedConfig , 'test.quickpickle' )
144+ passedConfig ,
145+ get ( resolvedConfig , 'quickpickle' ) ,
147146 ) as QuickPickleConfig ;
148147 config . todoTags = normalizeTags ( config . todoTags )
149148 config . skipTags = normalizeTags ( config . skipTags )
150149 config . failTags = normalizeTags ( config . failTags )
151150 config . concurrentTags = normalizeTags ( config . concurrentTags )
152151 config . sequentialTags = normalizeTags ( config . sequentialTags )
153152 } ,
154- transform : async ( src : string , id : string ) : Promise < string | undefined > => {
153+ async transform ( src : string , id : string ) {
155154 if ( featureRegex . test ( id ) ) {
156155 return renderGherkin ( src , config , id . match ( / \. m d $ / ) ? true : false )
157156 }
0 commit comments